Skip to content

Instantly share code, notes, and snippets.

@richardpascual
Last active June 23, 2021 23:24
Show Gist options
  • Save richardpascual/f9b657a3ceb049e8fbb609a14861412c to your computer and use it in GitHub Desktop.
Save richardpascual/f9b657a3ceb049e8fbb609a14861412c to your computer and use it in GitHub Desktop.
Compare two lists, identify if one is the reverse of the other.
#Write your function here
def reversed_list(lst1, lst2):
for index in range(len(lst1)):
if lst1[index] != lst2[len(lst2) - 1 - index]:
return False
return True
#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]))
@richardpascual
Copy link
Author

This didn't work. When it was a reverse of the other, the output result was None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment