+ 3
How do you end an else statement?
How do you end an else statement?
4 Réponses
+ 13
if... else is done like this:
some code before the if... else... block ...
if some_condition:
do this1
do this2
...
else:
do this3
....
do this4 # this is outside the if.. else... block
so the if... else... ends in this sample when codelines have the same indentation level as before starting the if ... else ... block.
+ 3
Thank you both
+ 1
If blah blah blah == blah blah blah :*the condition.
I am iron man *the work to be done if the the condition is true/satisfied
else: *not true(else ends with a :)
I am not iron man*work done when condition is not true/satisfied.
0
Sometimes the for or while loop can ends else. It do like if else. If there is break in the body of the loop, then else will not be executed.