Skip to content

Fixed bugs #2474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions strings/check_anagrams.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
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
arranged differently (ignoring the case).
>>> check_anagrams('Silent', 'Listen')
True
>>> check_anagrams('This is a string', 'Is this a string')
True
>>> check_anagrams('This is a string', 'Is this a string')
True
>>> check_anagrams('There', 'Their')
False
"""
return sorted(a.lower()) == sorted(b.lower())
return (
"".join(sorted(first_str.lower())).strip()
== "".join(sorted(second_str.lower())).strip()
)


if __name__ == "__main__":
from doctest import testmod

testmod()
input_A = input("Enter the first string ").strip()
input_B = input("Enter the second string ").strip()

Expand Down