How to Specify a Block of Code in Python


In this example we will show how to specify a block of code to be executed when the ‘for’ loop is finished in Python.

Source Code

for i in range(4):
    print(i)
else:
    print('Loop end!')

Output:

0
1
2
3
Loop end!
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments