Abatoor

Untitled

Dec 12th, 2021
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. def anagramCheck(str1, str2):
  2.    
  3.     list1 = list(str1)
  4.     list2 = list(str2)
  5.    
  6.     list1.sort()
  7.     list2.sort()
  8.  
  9.     position = 0
  10.     matches = True
  11.  
  12.     while position < len(str1) and matches:
  13.         if list1[position] == list2[position]:
  14.             position = position + 1
  15.         else:
  16.             matches = False
  17.  
  18.     return matches
  19.  
  20.  
  21. print(anagramCheck('ababa', 'aboba'))
  22.  
Advertisement
Add Comment
Please, Sign In to add comment