Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def string_scramble(word1, word2):
- """
- craeted empty list and u/case letters
- (if any) in words converted to l/case
- """
- x = []
- word1 = word1.lower()
- word2 = word2.lower()
- """
- each letter in word1 iterates thru word2 and
- appends letter unrepeated to x if found
- common
- """
- for i in range(len(word1)):
- for j in range(len(word2)):
- if word1[i] not in x:
- if word1[i] == word2[j]:
- x.append(word1[i])
- return x
- print(string_scramble('GraSS', 'grilled cheese'))
- print(string_scramble('Newark', 'New York'))
- print(string_scramble('Barbeque', 'Cheese Burger'))
- print(string_scramble('East Coast', 'New York'))
- print(string_scramble('GraSS', 'cheese'))
- print(string_scramble('Einstein', 'Newton'))
Add Comment
Please, Sign In to add comment