Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #I've never used unittest or done unit-testing so I didn't do it as I wouldn't be able to do it without Google
- def find_anagrams(list_of_strings, word):
- letters=list(word)
- anagrams=[]
- for i in list_of_strings:
- for j in letters:
- if j in i:
- exists=True
- else:
- exists=False
- break
- if exists==True:
- anagrams.append(i)
- print (anagrams)
- find_anagrams(["spare", "hello", "pears", "world", "reaps"], "parse") # Should return ["spare", "pears", "reaps"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement