+ 4

I need help with this python 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[0])

13th Jun 2019, 11:08 AM
William Brooks
William Brooks - avatar
1 Antwort
+ 6
you should use the len function, it returns the length of the array list = [1, 2, 3, 4] if len(list) % 2 == 0: print(list[0])
13th Jun 2019, 11:19 AM
Airree
Airree - avatar