Fixed bugs (#2474)

* fixed bug

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Du Yuanchao 2020-09-25 21:20:09 +08:00 committed by GitHub
parent 53c2a24587
commit a196a36514
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,9 @@
def check_anagrams(a: str, b: str) -> bool: """
wiki: https://en.wikipedia.org/wiki/Anagram
"""
def check_anagrams(first_str: str, second_str: str) -> bool:
""" """
Two strings are anagrams if they are made of the same letters Two strings are anagrams if they are made of the same letters
arranged differently (ignoring the case). arranged differently (ignoring the case).
@ -6,13 +11,21 @@ def check_anagrams(a: str, b: str) -> bool:
True True
>>> check_anagrams('This is a string', 'Is this a string') >>> check_anagrams('This is a string', 'Is this a string')
True True
>>> check_anagrams('This is a string', 'Is this a string')
True
>>> check_anagrams('There', 'Their') >>> check_anagrams('There', 'Their')
False False
""" """
return sorted(a.lower()) == sorted(b.lower()) return (
"".join(sorted(first_str.lower())).strip()
== "".join(sorted(second_str.lower())).strip()
)
if __name__ == "__main__": if __name__ == "__main__":
from doctest import testmod
testmod()
input_A = input("Enter the first string ").strip() input_A = input("Enter the first string ").strip()
input_B = input("Enter the second string ").strip() input_B = input("Enter the second string ").strip()