You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The anagram solution 1 return true when run with print(anagramSolution1('abcd','addcb')).
I think the problem is where after running the stillOK statement that return False, upon exiting if statement, it is assigned stillOK = True, which cause it to enter the while loop even when the length does not match.
I have added an else statement after the stillOK = False and it returns the expected result.
The anagram solution 1 return true when run with print(anagramSolution1('abcd','addcb')).
I think the problem is where after running the stillOK statement that return False, upon exiting if statement, it is assigned stillOK = True, which cause it to enter the while loop even when the length does not match.
I have added an else statement after the stillOK = False and it returns the expected result.
def anagramSolution1(s1,s2):
alist = list(s2)
pos1 = 0
if len(s1) != len(s2):
stillOK = False
The text was updated successfully, but these errors were encountered: