lundi 5 novembre 2018

Python one line if statement with two actions

I am trying to find a way to get two actions done in one line if statement, I can find a lot of answers to perform a single action in if statement one-liner but not for this. Is it even possible? I tried something like this but failed with ValueError - too many values to unpack (expected 2). Thanks.

g, er = "id", "err" if no_of_errs <= 1 else "ppd", "ers"

Aucun commentaire:

Enregistrer un commentaire