0

How do you do this

okay so I did if [0,2,4,6,8,10] % 2==0: print("wow that's a surprise") what did I do wrong?

26th Oct 2016, 2:38 PM
Tendai25
Tendai25 - avatar
3 odpowiedzi
+ 3
You want to check a condition for all elements of the list, right? In that case, do this: if all(i % 2 == 0 for i in [0,2,4,6,8,10]): print("wow that's a surprise")
26th Oct 2016, 2:56 PM
Zen
Zen - avatar
0
you cannot divide a list with integer. if you want to divide the length of list with integer, use len() function. if len([0,2,4,6,8,10]) ==0: print("something")
26th Oct 2016, 4:21 PM
Hammad Ilyas
Hammad Ilyas - avatar
0
ty zen and hammad
26th Oct 2016, 4:34 PM
Tendai25
Tendai25 - avatar