1.

What is the answer for this code? Fill in the blanks to print the first element of the list, if it contains even number of elements. list = [1, 2, 3, 4] if (list) % 2 == 0: print(list[ ])

Answer»

Python program to PRINT even numbers in a list

APPROACH 1 − Using enhanced for loop. Example. LIST1 = [11,23,45,23,64,22,11,24] # iteration for num in list1: # check if num % 2 == 0: print(num, end = " ") ...

Approach 2 − Using filter & lambda function. Example. list1 = [11,23,45,23,64,22,11,24] # lambda exp. ...

Approach 3 − Using list comprehension. Example.



Discussion

No Comment Found