list = [1, 2, 3, 4] if (list) % 2 == 0 : print(list[ ]) anyone help? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
- 5

list = [1, 2, 3, 4] if (list) % 2 == 0 : print(list[ ]) anyone help?

24th Mar 2017, 12:17 PM
Jay Sibley
Jay Sibley - avatar
8 Respuestas
0
if y=10, else x = 77
24th Mar 2017, 12:22 PM
Adam Cook
Adam Cook - avatar
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.
24th Mar 2017, 1:45 PM
Mark Derby
Mark Derby - avatar
0
No it's not fine
5th Sep 2020, 7:58 PM
Kajal Sharma
Kajal Sharma - avatar
0
list = [1, 2, 3, 4] if ...........(list) % 2 == 0: print(list[......]) help please
15th Dec 2020, 10:56 AM
chaimaa el bachiri
chaimaa el bachiri - avatar
0
list = [1, 2, 3, 4] if (list) % 2 == 0 : print(list[ ]) how to solve
6th Jan 2021, 9:49 AM
hiral rabadiya
hiral rabadiya - avatar
0
list = [1, 2, 3, 4] if len (list) %2 == 0: print (list[0])
21st Jan 2021, 11:51 AM
Yasin Kökdoğan
Yasin Kökdoğan - avatar
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 ✌
11th May 2021, 10:57 AM
Subhansh Dwivedi
Subhansh Dwivedi - avatar
0
list = [1, 2, 3, 4] if len (list) % 2 == 0 : print(list[ 0 ])
26th May 2021, 12:00 AM
Arturo Ramirez
Arturo Ramirez - avatar