Advertisement
Kingabdulazeez

Reading anagram assignment

May 28th, 2022
1,379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1.  
  2. def check(word, anagram):
  3.     # Code to find Anagrams in two words
  4.     first_word = input("Enter the first word:")  #This code allow input from user
  5.     second_word = input("Enter the second word:")
  6.  
  7.     #Converting the input into lower case
  8.     first_word = first_word.lower()
  9.     second_word = second_word.lower()
  10.  
  11.     #conditional statement to find if they are anagram
  12.     if(sorted(first_word) == sorted(second_word)):
  13.         print(f"The words {first_word} and {second_word} are anagram")
  14.     else:
  15.         print(f"The words {first_word} and {second_word} are not anagram")
  16. check("first_word","second_word")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement