MENU
Question -

Write a list comprehension that builds a list of the even numbers from 1 to 10 (inclusive).



Answer -

foo = [x for x in range(l, 11) if (x % 2) = = 0] print foo [2,4,6,8,10]

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×