0

HELP

hi everyone, could anyone help me with this exercise? i can't figure out what's missing after if list = [1, 2, 3, 4] if (list) % 2 == 0: print(list[0])

18th Jan 2021, 2:32 PM
elliot
6 Answers
+ 3
We cant perform % or modulus between list and integer. maybe the length would return an integer, hmm... elliot what do you think? đŸ€”đŸ€”
18th Jan 2021, 2:46 PM
noteve
noteve - avatar
+ 3
Read again the question, and find what the question is asking for.
18th Jan 2021, 3:12 PM
noteve
noteve - avatar
+ 2
found! I had to put "len" after "if", thank you all!
18th Jan 2021, 3:45 PM
elliot
+ 1
yes the problem is that it is a SoloLearn exercise of the Python course, "Control Structures" exercise "Module 3 Quiz" ... there is a blank space after the "if" to fill in but I have no idea what to put in it
18th Jan 2021, 3:11 PM
elliot
+ 1
What function or built-in method that takes a list as argument and return an integer value?
18th Jan 2021, 3:43 PM
HBhZ_C
HBhZ_C - avatar
0
You can iterate throw the list using for loop and then make the if condition in each iteration to check if the element is even for num in list: if num%2 == 0: ....
18th Jan 2021, 2:51 PM
HBhZ_C
HBhZ_C - avatar