Computer Science, asked by shahineetu23, 9 months ago

write a program to accept 2 string and check whether they are anagram ​

Answers

Answered by sushiladevi4418
1

Answer:

WAP to accept 2 string and check whether they are anagram.

Explanation:

aline1 = input('Enter the first word: ')

laine2 = input('Enter the second word: ')

def deleteSpaces(s):

   s_new = s.replace(" ","")

   return s_new

def anagramSolution2(s1,s2):

   list1 = list(deleteSpaces(s1))

   list2 = list(deleteSpaces(s2))

   print(list1)

   print(list2)

   list1.sort()

   list2.sort()

   pos = 0

   matches = True

   while pos < len(deleteSpaces(s1)) and matches:

       if list1[pos]==list2[pos]:

           pos = pos + 1

       else:

           matches = False

   return matches

Similar questions