Page 1 of 1

The original Python question and my code: And here's the provided solution: Why does for ..... != ........: return Fa

Posted: Thu Jul 14, 2022 2:12 pm
by answerhappygod
The original Python question and my code:
The Original Python Question And My Code And Here S The Provided Solution Why Does For Return Fa 1
The Original Python Question And My Code And Here S The Provided Solution Why Does For Return Fa 1 (107.08 KiB) Viewed 17 times
And here's the provided solution:
The Original Python Question And My Code And Here S The Provided Solution Why Does For Return Fa 2
The Original Python Question And My Code And Here S The Provided Solution Why Does For Return Fa 2 (27.76 KiB) Viewed 17 times
Why does
for ..... != ........: return Falsereturn True
return the correct answer, but in my code, I simplyjust reversed the order of the conditionby saying
for ...... == .......: return Truereturn False
and then I got a wrong answer?
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. > Hint
def reversed_list(lst1, lst2): for index in range(len(lst1)): if lst1[index] != lst2[len(lst2) - 1 - index]: return False return True