Skip to content

Commit b4feffa

Browse files
Merge pull request #4 from Ar-tech937/main
Create anagram_checker.py
2 parents 7748919 + a9f6700 commit b4feffa

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Python/anagram_checker.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
def anagram_checker(s1,s2):
2+
list1 = list(s1)
3+
list2 = list(s2)
4+
5+
list1.sort()
6+
list2.sort()
7+
8+
pos = 0
9+
matches = True
10+
11+
while pos < len(s1) and matches:
12+
if list1[pos] == list2[pos]:
13+
pos = pos + 1
14+
else:
15+
matches = False
16+
17+
return matches
18+
19+
# Example -
20+
# print(anagram_checker('abcde','edcba'))

0 commit comments

Comments
 (0)