Ok so below are two different versions of my solution to the 5th problem on this page " Reversed Loops "
i get THAT the first one doesnt really work… and i FEEL there is a why… but im struggling to SEE it… can someone EXPLAIN what is happening INSIDE the IF/ELSE version of my logic that prevents from getting the right answer under False circumstances
Non Functional Code Block
#Write your function here
def reversed_list(lst1 , lst2):
new_list = []
for index in range(len(lst1)):
if lst1[index] != lst2[len(lst2) -1- index]:
return False
else:
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]))
Functional Code Block
#Write your function here
def reversed_list(lst1 , lst2):
new_list = []
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]))