Q. Consider a list ML = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. Write code using a list comprehension that takes the list ML and makes a new list that has only the even elements of this list in it.


Answer =

ML = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
newlst = [i for i in ML if i % 2 == 0]
print (newlst)

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post