Last active
September 3, 2021 16:23
-
-
Save ppeuchin/4b29129854214d7520e856c90bed08d8 to your computer and use it in GitHub Desktop.
A program that reads two strings from the user and determines whether or not they are anagrams.
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
# Two words are anagrams if they contain all of the same letters, but in a different order. | |
txt1 = input("Enter a string: ") | |
txt2 = input("Enter another string: ") | |
counts = 0 | |
for i in txt2: | |
if i in txt1: | |
counts += 1 | |
else: | |
counts += 0 | |
if counts == len(txt1) & counts == len(txt2): | |
print(txt1, "and", txt2, "are anagrams!") | |
else: | |
print(txt1, "and", txt2, "are not anagrams!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment