Skip to content

Instantly share code, notes, and snippets.

@ppeuchin
Last active September 3, 2021 16:23
Show Gist options
  • Save ppeuchin/4b29129854214d7520e856c90bed08d8 to your computer and use it in GitHub Desktop.
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.
# 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