mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-22 08:21:12 -04:00
Update is_anagram.py
This commit is contained in:
parent
2d0842019d
commit
b14d9fcee2
1 changed files with 2 additions and 10 deletions
|
@ -11,16 +11,8 @@ def is_anagram(string1, string2) -> bool:
|
|||
if len(string1) != len(string2):
|
||||
return False
|
||||
|
||||
for char in string1:
|
||||
if char not in string2:
|
||||
for c in string1:
|
||||
if c not in string2:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
print('Testing is_anagram()...')
|
||||
string1 = "listen"
|
||||
string2 = "silent"
|
||||
print(f'Is {string1} an anagram of {string2}?: {is_anagram(string1, string2)}')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue