Python ? (conditional/ternary) operator for assignments

Python has such an operator:

variable = something if condition else something_else

Alternatively, although not recommended (see karadoc’s comment):

variable = (condition and something) or something_else

Leave a Comment

error code: 523