+ 3
fill the blank
What should I put in the blank for print first item of list if one element of list is even !? list = [1,2,3,4] if ___ (list) % 2 == 0 : print (list[0])
3 Answers
+ 6
meta to add on to what Lachlan said I have this code
https://code.sololearn.com/cSNYMigx1d0v/?ref=app
+ 5
You could do a "for" loop to iterate over every item in the list and check if it is even for every item like this:
list = [1,2,3,4]
for item in list:
if item % 2 == 0:
print(list[0])
Check out the tutorial for "for" loops in the python tutorial on Sololearn.
+ 3
tnx a lot