On Wed, 16 Mar 2016 09:34 pm, BartC wrote:

> (BTW why does Python have 'elif' when if-else is all that is really
> needed?)

To save indentation.


if condition:
    block
else:
    if other:
        block
    else:
        if third:
            block
        else:
            block


versus:

if condition:
    block
elif other:
    block
elif third:
    block
else:
    block


Python could have spelled "elif" as "else if", but that's just a matter of
spelling. Either way, the important thing is that the else-if/elif keeps
the same indentation as the if.



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to