Python else statement
Else statment can be used in:
- if else statment
- loops
- try-except statement
If else statment
- if-else
Loops
- for-in loop
- while loop
Try except statement
- try-except
Interview Questions
1. When will else-block be excuted in a loop?
When no break occurs.
2. When will else-block be excuted in a try-except statement?
When no exception occurs.
3. When will else-block be excuted in a try-catch statment - after or before finaly statment?
Before finaly.