Hi all, I have a quick question on the answer to the Reversed list challenge in the Loops module
https://www.codecademy.com/courses/learn-python-3/lessons/python-functions-loops-cc/exercises/reversed
The challenge is:
Create a function named reversed_list()
that takes two lists of the same size as parameters named lst1
and lst2
.
The function should return True
if lst1
is the same as lst2
reversed. The function should return False
otherwise.
For example, reversed_list([1, 2, 3], [3, 2, 1])
should return True
.
and the correct code for the answer is:
def reversed_list(lst1, lst2):
for index in range(len(lst1)):
if lst1[index] != lst2[len(lst2) - 1 - index]:
return False
return True
My question is: why do we just say “return True” at the end, instead of “else return True”?
Thanks!