what is the diffrence between else clause of if else and else clause of python loops in python?
Answers
Explanation:
.The else of an if/else signifies the
start of a code block which will only
execute if the conditional (after the if
results in a False value.
.The else after loops signify the start
of a code block which is executed only
when the loop executes fully - i.e. there
is no break, or return or anything
else executed within the loop.
.The else after a try/except
signifies the start of a code block,
which is only executed if there is no
exception raised within the try block.
In Python 3 : The else of an if / else signifies the start of a code block which will only execute if the conditional (after the if ) results in a False value. ... The else after a try / except signifies the start of a code block, which is only executed if there is no exception raised within the try block.