I am trying to check a condition that provides a TRUE value for if I have two lists that are reversed from one another, and a FALSE value otherwise.
Here is my code:
def reversed_list(lst1, lst2):
for index in range(len(lst1)):
if lst1[index] == lst2[-index - 1]:
print(reversed_list([1, 2, 3], [3, 2, 1]))
print(reversed_list([1, 5, 3], [3, 2, 1]))
When I run the code, both sets of lists are TRUE even though the second set is FALSE given that 3, 2, 1 is not the inverse of 1, 5, 3.
While I understand the answer key provided by Codecademy, why am I wrong here? I thought that the negative index corresponds to the position at the end of the list.