Ordered-containment of a string(D) - MAKE MY PYTHON CODE BETTER
PLEASE SUGGEST THE BEST SOLUTION FOR THIS QUESTION This is the question: A string S2 is said is said to be order-contained in another string S1 if all the letters of S2 is present in S1 and order of occurrence of letters of S2 in S1 is same as in S2. For example, elephant contains ant, hat but not tap. Given two strings S1 and S2, write a code to Print 'Yes' if S2 is order contained in S1 and 'No' otherwise. All letters in the input will be lowercase in the given string with no spaces Input Format First line contains the string, S1 Second line contains the string, S2 Output format Print Yes if S2 is order contained in S1 and Print No otherwise This is my code in python def leftout(s): s1 = '' for i in range(1,len(s)): s1 = s1 + s[i] return s1 s2 = str(input()) s3 = str(input()) while((s2 != "")&(s3 != "")): if(s2[0] == s3[0]): s3 = leftout(s3) s2 = leftout(s2) if(s3 == ""): print("Yes") else: print("No")