Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #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
  2.  
  3. def find_anagrams(list_of_strings, word):
  4. letters=list(word)
  5. anagrams=[]
  6.  
  7. for i in list_of_strings:
  8. for j in letters:
  9. if j in i:
  10. exists=True
  11. else:
  12. exists=False
  13. break
  14. if exists==True:
  15. anagrams.append(i)
  16.  
  17.  
  18. print (anagrams)
  19.  
  20.  
  21.  
  22.  
  23. find_anagrams(["spare", "hello", "pears", "world", "reaps"], "parse") # Should return ["spare", "pears", "reaps"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement