- 5
list = [1, 2, 3, 4] if (list) % 2 == 0 : print(list[ ]) anyone help?
8 Réponses
0
if y=10, else x = 77
0
Jay in your code I guess you were trying to print the list of all even numbers from 1 to 4. If so then use list comprehension;
list = [a for a in range(1,5) if a%2==0]
print(list)
It should give you what you want.
0
No it's not fine
0
list = [1, 2, 3, 4]
if ...........(list) % 2 == 0:
print(list[......])
help please
0
list = [1, 2, 3, 4]
if
(list) % 2 == 0
:
print(list[
]) how to solve
0
list = [1, 2, 3, 4]
if len (list) %2 == 0:
print (list[0])
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
])
This is the correct answer .
reason : Since the question is asking to print the first element of list if the list is even so we use len(list) in the if statement .
references : Yasin Kokdogan ✌
0
list = [1, 2, 3, 4]
if
len
(list) % 2 == 0
:
print(list[
0
])