when I evaluate the following operation
0 if True else 1 + 1 if False else 1
it evaluates to 0 however when I write with brackets like
as ternary operator is read from left to right and + has lower precedence than conditional operators. So, these two are equivalent:
ternary operator
left to right
+
>>> 0 if True else 1 + 1 if False else 1 0 >>> 0 if True else ( (1 + 1) if False else 1) 0