use python 3 language please ! def sum_evens_2d(xss): Given a \"two-dimensional
ID: 3757582 • Letter: U
Question
use python 3 language please !
def sum_evens_2d(xss): Given a "two-dimensional list" of integers - that is, a list where each value in it is a list of integers - find all the even numbers and sum them together. You will need more than a single loop for this! (xss is pronounced "ecksezez".) o assume that xss is a list where each value is a list of integers. o Restriction: you may not call sum). (It would have included the odds anyways). o Examples: sum_evens_2d([[1,2,3], [4,5,6]]) sum_evens_2d([[1,3,51, [7,9,11]]) sum_evens_2d([[1,2,3],[4,5],[6],[7,8,9]])2+4+6+8 2+4+6 12 20Explanation / Answer
def sum_evens_2d(ll): total = 0 for lst in ll: for num in lst: if num % 2 == 0: total += num return total print(sum_evens_2d([[1, 2, 3], [4, 5, 6]]))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.