Skip to content

Commit 5e0fc94

Browse files
committed
Added another version of the program "is_anagram.py" which uses python3 collections to make the program more concise.
1 parent e8b89a9 commit 5e0fc94

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

is_anagram_using_collections.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Check if two strings are anagrams of each other
2+
3+
4+
from collections import Counter
5+
6+
def is_anagram(str1, str2):
7+
return Counter(str1) == Counter(str2)
8+
9+
10+
result = is_anagram("hello", "billion")
11+
print(result) # False
12+
13+
result = is_anagram("million", "million")
14+
print(result) # True

0 commit comments

Comments
 (0)