Implement function evenrow() that takes a 2D list of integers and returns True i
ID: 3546936 • Letter: I
Question
Implement function evenrow() that takes a 2D list of integers and returns True if each row of the table sums up to an even number and False otherwise (ie if some row sums up to an odd number)
>>>evenrow([[1,3],[2,4],[0,6]])
True
>>>evenrow([[1,3,2],[3,4,7],[0,5,2]])
False
Explanation / Answer
def evenrow(lst): for i in range(len(lst)-1): if sum(lst[i]) % 2 != 0: # here is the problem, it only iterates over the first item in the lst [1, 3] - i cant figure this out - range problem? return False return True
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.