I have a list like this
a = [1,0,6,9,6,0,6,0,1,4,0,7,5,0]
I want to create a conditional statement like this:
if a[1,3,8,13] != 0:
do something
And this code is obviously wrong. It has to be like this:
if a[1] != 0 and a[3] != 0 and a[8] != 0 and a[13] != 0:
do something
I want to know if there is any more elegant way for writing the multiple conditional statements using lambda or loop in my case. Let say my list is like 100 in length, and I need to make a conditional statements for 57 columns of the list. I probably don't want to write them all out in such a fashion... thanks
Aucun commentaire:
Enregistrer un commentaire