- 2

Do anyone know what is "?"

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])

16th Dec 2020, 5:40 AM
Ammar Syahmi
Ammar Syahmi - avatar
4 Answers
+ 8
Looks like a quiz from python course. Hint: You can think about any list function to get the total number of elements in a list. Btw, you can check the comments section if you can't understand any quizzes
16th Dec 2020, 5:59 AM
Simba
Simba - avatar
+ 1
Your code example is in Python Python ternary operator isn't using ? or :
16th Dec 2020, 6:13 AM
Ipang
0
Module quiz? Which module / chapter? I don't remember this one.
16th Dec 2020, 6:04 AM
Ipang
- 1
? Is a ternary operator....it executes like this... Variable= expression1 ? expression2 : expression 3 Or in layman terms- If(expression1) { variable=expression2; } else { variable=expression3; } Here,expression1 is the condition to be evaluated.If the condition (expression1) is true then expression2 will be executed and if expression1 ks false then expression3 will be executed..
16th Dec 2020, 6:11 AM
Prateek Lohani
Prateek Lohani - avatar