samedi 21 mars 2020

Simplify conditions in python

I need to check different elements of a a list with certain conditions, but the script it's really a pain to read, so I need something that can simplify this mess:

if element[0] != "]" and element[0] != "[" and element[0] != "*" and element[0] != "."element[0] != "," and element[0] != "-":
                tmp.append(element[0])

Is there a way to make it easier and with less conditions? I should also add other conditions.

Aucun commentaire:

Enregistrer un commentaire