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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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 15 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 15 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply