Am I right in thinking I can't put an if-statement and the corresponding else-statement on one line in Python?
NB:
variable = value1 if condition else value2
is NOT two statements. It's one statement which can take the value of one of two expressions.
I want to do something like
if condition a=value1 else b=value2
Am I right in thinking this requires a full if-else in Python? Like
if condition:
a=value1
else:
b=value2
Note as I already noted above (this is inherent to the definition of what is a statement and what is an expression, with which every programmer should be familiar), because I am I assigning two different variables, the above is quite different to
if condition:
a=value1
else:
a=value2
where I could of course simply use a conditional expression
a = value1 if condition else value2
Therefore my question is not a duplicate of Does Python have a ternary conditional operator?