Guest User

Untitled

a guest
Dec 10th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. def string_scramble(word1, word2):
  2. """
  3. craeted empty list and u/case letters
  4. (if any) in words converted to l/case
  5. """
  6. x = []
  7. word1 = word1.lower()
  8. word2 = word2.lower()
  9. """
  10. each letter in word1 iterates thru word2 and
  11. appends letter unrepeated to x if found
  12. common
  13. """
  14. for i in range(len(word1)):
  15. for j in range(len(word2)):
  16. if word1[i] not in x:
  17. if word1[i] == word2[j]:
  18. x.append(word1[i])
  19. return x
  20.  
  21. print(string_scramble('GraSS', 'grilled cheese'))
  22. print(string_scramble('Newark', 'New York'))
  23. print(string_scramble('Barbeque', 'Cheese Burger'))
  24. print(string_scramble('East Coast', 'New York'))
  25. print(string_scramble('GraSS', 'cheese'))
  26. print(string_scramble('Einstein', 'Newton'))
Add Comment
Please, Sign In to add comment