Last active
September 19, 2022 13:39
-
-
Save xenups/6ecd84d7902626726757516ec05bf5ec to your computer and use it in GitHub Desktop.
anagram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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