File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1- def check_anagrams (a : str , b : str ) -> bool :
1+ """
2+ wiki: https://en.wikipedia.org/wiki/Anagram
3+ """
4+
5+
6+ def check_anagrams (first_str : str , second_str : str ) -> bool :
27 """
38 Two strings are anagrams if they are made of the same letters
49 arranged differently (ignoring the case).
510 >>> check_anagrams('Silent', 'Listen')
611 True
712 >>> check_anagrams('This is a string', 'Is this a string')
813 True
14+ >>> check_anagrams('This is a string', 'Is this a string')
15+ True
916 >>> check_anagrams('There', 'Their')
1017 False
1118 """
12- return sorted (a .lower ()) == sorted (b .lower ())
19+ return (
20+ "" .join (sorted (first_str .lower ())).strip ()
21+ == "" .join (sorted (second_str .lower ())).strip ()
22+ )
1323
1424
1525if __name__ == "__main__" :
26+ from doctest import testmod
27+
28+ testmod ()
1629 input_A = input ("Enter the first string " ).strip ()
1730 input_B = input ("Enter the second string " ).strip ()
1831
You can’t perform that action at this time.
0 commit comments