mardi 3 octobre 2017

Short "if" in python in case of append into array

Not sure whether the subject is correct, but I would like to use short IF instruction in such code:

arr.append( data if not data in arr )

But this code returns:

SyntaxError: invalid syntax

Is there any other option?

Thanks.

Aucun commentaire:

Enregistrer un commentaire