Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- str_1 = "the cow jumped over the moon"
- str_2 = "the moon cow jumped over the"
- def is_permutation(str_1, str_2):
- str_1 = str_1.replace(" ", "")
- str_2 = str_2.replace(" ", "")
- if len(str_1) != len(str_2):
- return False
- for char in str_1:
- if char in str_2:
- str_2 = str_2.replace(char, "")
- return len(str_2) == 0
- print(is_permutation(str_1, str_2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement