Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is a python code and I want to covert it from for loop into while loop. can anyone help me with that, please from
This is a python code and I want to covert it from for loop into while loop. can anyone help me with that, please
from typing import List
def only_evens(lst: List[List[int]]) -> List[List[int]]:
"""Return a list of the lists in lst that contain only even integers.
>>> only_evens([[1, 2, 4], [4, 0, 6], [22, 4, 3], [2]])
[[4, 0, 6], [2]]
"""
even_lists = []
for sublist in lst:
iseven=True
for element in sublist:
if element%2!=0:
iseven=False
if iseven==True:
even_lists.append(sublist)
return even_lists
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