Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. def x_ian(x, word):
  2. """
  3. Given a string x, returns True if all the letters in x are
  4. contained in word in the same order as they appear in x.
  5.  
  6. >>> x_ian('eric', 'meritocracy')
  7. True
  8. >>> x_ian('eric', 'cerium')
  9. False
  10. >>> x_ian('john', 'mahjong')
  11. False
  12.  
  13. x: a string
  14. word: a string
  15. returns: True if word is x_ian, False otherwise
  16. """
  17. if len(x)>len(word):
  18. return False
  19. if len(x)==0:
  20. return True
  21. else:
  22. if x[0]==word[0]:
  23. return x_ian(x[1:],word[1:])
  24. else:
  25. return x_ian(x,word[1:])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement