Last active
November 12, 2017 12:31
-
-
Save 007bsd/81f2dc70ad7af7e4709298796706114a to your computer and use it in GitHub Desktop.
Anagrams code for python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import string | |
| def ara_anagrams(): | |
| str1 = input("Please input your first string : ") | |
| str2 = input("Please input your second string : ") | |
| exclude = sorted(set(string.punctuation)) | |
| str1 = ''.join(ch for ch in str1 if ch not in exclude) | |
| str2 = ''.join(ch for ch in str2 if ch not in exclude) | |
| if ''.join(sorted(set(str1.replace(" ", "").lower().strip()))) == ''.join( | |
| sorted(set(sorted(str2.replace(" ", "").lower().strip())))): | |
| return True | |
| else: | |
| return False | |
| print(ara_anagrams()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment