FAQ: Code Challenge: Loops - Reversed List

3 posts were merged into an existing topic: Sharing solutions

2 posts were split to a new topic: Why doesn’t this code work?

4 posts were split to a new topic: Is this code okay?

3 posts were merged into an existing topic: How can I iterate over a list backward?

2 posts were merged into an existing topic: Sharing solutions

2 posts were split to a new topic: What do you think of this solution?

3 posts were merged into an existing topic: How can I iterate over a list backward?

12 posts were merged into an existing topic: Did you double check the placement of return?

3 posts were split to a new topic: Why doesn’t this code work?

5 posts were merged into an existing topic: Did you double check the placement of return?

2 posts were split to a new topic: Why don’t we use else?

10 posts were merged into an existing topic: Could I solve this using reverse()? Is it efficient?

2 posts were merged into an existing topic: Did you double check the placement of return?

3 posts were merged into an existing topic: Did you double check the placement of return?

5 posts were split to a new topic: Boredless tourist question?

2 posts were merged into an existing topic: Did you double check the placement of return?

A post was split to a new topic: The next lesson won’t load?

3 posts were merged into an existing topic: Did you double check the placement of return?

A post was merged into an existing topic: Sharing solutions

I don’t understand the logic here, can someone explain why my code is wrong?
Thanks a lot!

def reversed_list(lst1, lst2):
  
  #lst1[0] = lst2[-1]
  #lst1[1] = lst2[-2]
  #lst1[2] = lst2[-3]
  
  for index in range(len(lst1)):
    for index in range(len(lst2)):
      if (lst1[index] == lst2[-1-index]):
        return True
      else:
        return False