Python @ DjangoSpin

PyPro #93 Anagram Test

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon
Reading Time: 1 minutes

Anagram Test in Python

Anagram Test in Python

Given two strings, write a Python program for Anagram Test i.e. check if they are anagrams.

stringOne = 'William Shakespeare'
stringTwo = 'I am a weakish speller'

setOfCharactersInStringOne = set(sorted(stringOne.upper()))
setOfCharactersInStringTwo = set(sorted(stringTwo.upper()))

if orderedListOfCharactersInStringOne == orderedListOfCharactersInStringTwo:
	print("These are anagrams!")
else:
	print("Not anagrams....")

See also:

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon

Leave a Reply