Python compare reversed list help

Hello, I have written the below code to try and answer one of the python challenges for checking if a list reversed is the same as another list. I have ended up trying to do it a completely different method to what the way to do it example was. I’m just wondering if it is actually possible to do how i have attempted to do it?
I am trying to make a new list that is the reverse of list 1 and then compare the indices of each list to see if they are the same. On both of the reversed lists i get a false though which obviously the first should be true

#Write your function here
def reversed_list(lst1, lst2):
  reverse1 = []
  reverse1.append(lst1.reverse())
  for i in range(len(lst1)):
    if reverse1[i] == lst2[i]:
      return True
    else:
      return False
#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]))

Welcome to the forums. Can you please format your code so people can help you?

See:

Thanks for your reply, I changed my original code and have got it working now as below. Im sure i tried this first of all and it didn’t work so i must have made a small error somewhere

#Write your function here
def reversed_list(lst1, lst2):
  lst1.reverse()
  if lst1 == lst2:
    return True
  else:
    return False
#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]))

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.