This code isn’t making any sense to me. Here’s what I’ve got:
def reversed_list(lst1, lst2):
for i in range(len(lst1)):
if lst1[i] == lst2[(-i - 1)]:
Here’s my problem:
when I have the second print() run through my code, it shows up as true.
The two lists are lst1 = [1, 5, 3] and lst2 = [3, 2, 1]
So in theory, on the second run-through of the loop, it’s doing this:
if lst1 == lst2[-1 - 1]:
I know that lst1 is equal to 5 and lst2[-1 -1] is lst2[-2] which is equal to 2. These are clearly not equal, yet I’m getting a True return.
Can someone explain why this is?