We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9351889 commit 2eca716Copy full SHA for 2eca716
strings/check_anagrams.py
@@ -0,0 +1,22 @@
1
+def check_anagrams(a: str, b: str) -> bool:
2
+ """
3
+ Two strings are anagrams if they are made of the same letters
4
+ arranged differently (ignoring the case).
5
+ >>> check_anagrams('Silent', 'Listen')
6
+ True
7
+ >>> check_anagrams('This is a string', 'Is this a string')
8
9
+ >>> check_anagrams('There', 'Their')
10
+ False
11
12
+ return sorted(a.lower()) == sorted(b.lower())
13
+
14
15
+if __name__ == "__main__":
16
+ input_A = input("Enter the first string ").strip()
17
+ input_B = input("Enter the second string ").strip()
18
19
+ status = check_anagrams(input_A, input_B)
20
+ print(
21
+ f"{input_A} and {input_B} are {'' if status else 'not '}anagrams."
22
+ )
0 commit comments