samedi 22 avril 2017

Simplified the condition in list

The code below needs three lines. Is it possible to simplified to one line?

code = [x for x in code if not 'W' in x]
code = [x for x in code if not '06501' in x]
code = [x for x in code if not '06502' in x]

I was trying this but did not work

code = [x for x in code if not 'W' or if not '06501' or if not '06502' in x]

Aucun commentaire:

Enregistrer un commentaire