0
a question in python tutorial
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[___])
2 Answers
+ 3
Hints:
1. If a number is even, what's the remainder when we divide by 2?
2. The function for finding the size of a list discussed here:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2433/?ref=app
3. Accessing an element at a certain position of a list is discussed here:
https://www.sololearn.com/learn/Python/2431/?ref=app
+ 1
Hint:
It means if list contain even numbers.means then length of list will give you 0 remainder with 2.because every even give 0 remainder with 2.here you can use len built in function.
If this condition is right then print first element of the list means first element has 0 index like this.
print(list[0])