Skip to content

Instantly share code, notes, and snippets.

@xenups
Last active September 19, 2022 13:39
Show Gist options
  • Save xenups/6ecd84d7902626726757516ec05bf5ec to your computer and use it in GitHub Desktop.
Save xenups/6ecd84d7902626726757516ec05bf5ec to your computer and use it in GitHub Desktop.
anagram
def convert_to_dikt(s):
dikt = {}
for word in s:
if dikt.get(word):
dikt[word] = dikt[word] + 1
else:
dikt[word] = 1
print(dikt)
return dikt
def is_anagram(s1, s2):
if convert_to_dikt(s1) == convert_to_dikt(s2):
return True
return False
print(is_anagram("race", "care"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment