Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

Students also viewed these Databases questions

Question

Write the difference between sexual and asexual reproduction.

Answered: 1 week ago

Question

What your favourite topic in mathematics?

Answered: 1 week ago

Question

Briefly describe vegetative reproduction in plants.

Answered: 1 week ago

Question

=+Where does the focus of labor relations lie? Is it collective

Answered: 1 week ago