Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. str_1 = "the cow jumped over the moon"
  2. str_2 = "the moon cow jumped over the"
  3.  
  4. def is_permutation(str_1, str_2):
  5. str_1 = str_1.replace(" ", "")
  6. str_2 = str_2.replace(" ", "")
  7.  
  8. if len(str_1) != len(str_2):
  9. return False
  10.  
  11. for char in str_1:
  12. if char in str_2:
  13. str_2 = str_2.replace(char, "")
  14. return len(str_2) == 0
  15.  
  16. print(is_permutation(str_1, str_2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement