I have the scenario something like this.
a = 3
b = 5
c = 7
# using ternary operator now,
a= 1; c = 1 if a < b else a = 2 ; c = 2
SyntaxError: can't assign to conditional expression
But I get error when I use assignment operator on both the sides ( Error Shown Above in bold )
If I use it on one side like a = 1 ; c = 1 if a < b else b works absolutely fine.
So question is How to use multiple statements in Python Ternary Operator.
Aucun commentaire:
Enregistrer un commentaire