Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7eeeedb

Browse files
Merge pull request devAmoghS#14 from rishitc/master
Improved the program: is_anagram.py
2 parents a777103 + 5e0fc94 commit 7eeeedb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎is_anagram_using_collections.py‎

Lines changed: 14 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /