Important Notice:

Using else with for Loop

Using else with for Loop

18 views 1 min read
Program 17: Using else with for Loop
 
for i in range(1, 6):
    print(i)
else:
    print("Loop completed successfully")

Output:

1
2
3
4
5
Loop completed successfully

Explanation:
 जब for loop बिना break के पूरा हो जाता है, तो else execute होता है।

Related Notes