0

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 len(list )%2 ==0 print (list [ 0 ]) why it is len after if

23rd Dec 2016, 12:23 PM
SealCLi
SealCLi - avatar
9 Answers
+ 7
"len" gives you the number of elements in the list. As you want to find out if the number of elements is even or odd you have to use the "len" operator.
23rd Dec 2016, 12:33 PM
Simon
Simon - avatar
+ 5
len, :, 0
15th Sep 2020, 8:59 AM
Saran M
Saran M - avatar
+ 5
list =[1 ,2 ,3 ,4 ] if len(list )%2 ==0 print (list [ 0 ]) bcz len meaning check length of this list so after if check that list
29th Dec 2020, 10:20 AM
Vijayanathan Menakan
Vijayanathan Menakan - avatar
+ 2
A computer runs codes One Line after the other. First , a new list of even numbers is generated[0,2,4,] Secondly, the first element[0] is then printed out.
25th Dec 2016, 12:08 AM
Julius Nji
Julius Nji - avatar
0
len : 0
10th Feb 2021, 11:54 AM
Md Momin Uddin Hridoy
Md Momin Uddin Hridoy - avatar
0
list = [10,11,12,13] if len(list)%2 ==0: print(list[0])
20th May 2021, 2:13 PM
Madhavareddy
Madhavareddy - avatar
0
list =[1,2,3,4] if len(list) % 2 == 0: print(list[0])
28th May 2022, 12:33 AM
Mark Judson Kreigth Allccaco Castro
- 8
completed it mate
20th Nov 2018, 10:21 AM
halex
- 10
first, you play roblox and then you ask yourself I need a girlfriend orrrr you think about your weird ddream that happened today and you feel something like............... I have no more characters remaining .... boomer also goodbye P.S I'm stupid
26th Sep 2020, 3:50 PM
Valdas
Valdas - avatar