Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Lists of even integers 1 / 4 This problem has you write a nested loop to process a list of list of int, and accumulate
Lists of even integers
This problem has you write a nested loop to process a list of list of int, and accumulate a list of list of int. The starter code provides an accumulator for the result and a loop over the lists, and you need to write the code that checks whether sublist contains only even ints.
You'll probably want a oneway flag: a Boolean variable that starts out as True and is set to False if you find an odd int in the sublist. You'll need to check the value of this variable to figure out whether to append sublist to the evenlists accumulator.
def onlyevenslst: listlistint listlistint:
Return a list of the lists in lst that contain only even integers.
onlyevens
evenlists
for sublist in lst:
# write your code here please read above for a suggested approach
return evenlists
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started