File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ == Anagram Check ==
3
+ An anagarm is a word/ phrase that can be formed by rearranging
4
+ the characters of another word/ phrase, typically using each
5
+ character only once.
6
+ for example, firstWord = listen, secondWord = silent
7
+ return value will be True.
8
+ https://en.wikipedia.org/wiki/Anagram
9
+ """
10
+
11
+
12
+ def anagram (firstWord : str , secondWord : str ) -> bool :
13
+ """
14
+ >>> anagram(listen, silent)
15
+ True
16
+ >>> anagram(rat, bat)
17
+ False
18
+ >>> anagram(tool, loot)
19
+ True
20
+ """
21
+
22
+ flag = 0
23
+ for ele in firstWord :
24
+ if ele in secondWord :
25
+ flag = 1
26
+ continue
27
+ else :
28
+ flag = 0
29
+ break
30
+ return True if (flag ) else False
31
+
32
+
33
+ if __name__ == "__main__" :
34
+ firstWord = input ("Enter the first word: " ).strip ()
35
+ secondWord = input ("Enter the second word: " ).strip ()
36
+ if anagram (firstWord , secondWord ):
37
+ print (f"{ firstWord } and { secondWord } are Anagrams." )
38
+ else :
39
+ print (f"{ firstWord } and { secondWord } are not Anagrams." )
You can’t perform that action at this time.
0 commit comments