diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index dba85db67b65e2..6c4ede76980509 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -2423,6 +2423,14 @@ The expression ``x if C else y`` first evaluates the condition, *C* rather than If *C* is true, *x* is evaluated and its value is returned; otherwise, *y* is evaluated and its value is returned. +Conditional expressions group from right to left, so +``a if b else c if d else e`` means ``a if b else (c if d else e)``:: + + >>> 'spam' if True else 'eggs' if False else 'ham' + 'spam' + >>> ('spam' if True else 'eggs') if False else 'ham' + 'ham' + See :pep:`308` for more details about conditional expressions.