I am a bit stuck on 5. Reversed List on this page of advanced challenges
I can see the suggested answer and understand it. However, I came up with a different solution that seems to get the same results and I’m not sure why it isn’t being marked as correct.
The code I tried was:
#Write your function here
def reversed_list(lst1, lst2):
i = -1
for num in lst1:
if num != lst2[i]:
return False
elif i == (0 - len(lst1)) and num == lst2[i]:
return True
else:
i -= 1
#Uncomment the lines below when your function is done
print(reversed_list([1, 2, 3], [3, 2, 1]))
print(reversed_list([1, 5, 3], [3, 2, 1]))
It seems to get the correct answers, and the logic makes sense to me. However, when I try to check my work, I just get the message:
reversed_list([], [])
should have returned True
, and it returned None
I’m not sure what this error means because it did return True and False as far as I can tell. I don’t see it ever returning None? So any advice would be appreciated.