I am writing a function that takes two strings as parameters, turns them in lists, and then returns an index of where the two strings differ:
def ss(line1,line2):
count = 0
list1 = line1.split()
list2 = line2.split()
for word in list1:
if word is not list2[count]:
return count
else:
count += 1
ss("Why is this not working?", "Why is this not working?")
The output I get is that my count is whatever I set it to initially (e.g., "0"). As far as I can see, it should be updating the count and then reiterating through the lists to compare the next indexes?
What do I not understand about how for-loops work?
Thanks.