Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def x_ian(x, word):
- """
- Given a string x, returns True if all the letters in x are
- contained in word in the same order as they appear in x.
- >>> x_ian('eric', 'meritocracy')
- True
- >>> x_ian('eric', 'cerium')
- False
- >>> x_ian('john', 'mahjong')
- False
- x: a string
- word: a string
- returns: True if word is x_ian, False otherwise
- """
- if len(x) == 1:
- return x in word
- else:
- if word.find(x[0]) > word.find(x[1]):
- return False
- else:
- try:
- return x_ian(x[1:], word[word.index(x[0]):])
- except ValueError:
- return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement