Nov-07-2021, 07:48 AM
It is excellent practice to use the conditional operator. It was introduced in Python 2.5, because people complained that Python lacked a ternary operator such as C's
x = a ? b : c
. Before that, people would sometimes use ersatz expressions such assign = ('', '-')[n < 0]