MacSG

114-Final-2

May 17th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. #Anagram
  2. def is_anagram(str1, str2):
  3.    
  4.     str3 = ''
  5.     for char in str1:
  6.         str3 += char
  7.     for i in range(len(str2)):
  8.         str3 = str3.replace(str2[i],'')
  9.        
  10.     return len(str3) == 0
  11.  
  12. #Main Program
  13. str1 = input("Enter first string: ")
  14. str2 = input("Enter second string: ")
  15.  
  16. if is_anagram(str1, str2):
  17.     print("Strings \"%s\" and \"%s\" are anagram."%(str1, str2))
  18. else:
  19.     print("Strings \"%s\" and \"%s\" are not anagram."%(str1, str2))
Advertisement
Add Comment
Please, Sign In to add comment