Skip to content

How to use else statement in for and while loop in python

Notifications You must be signed in to change notification settings

BhargavKadali39/else_in_loops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

else_in_loops

How to use else statement in for and while loop in python

Yes, that's true we can use else statement in loops like for and else,
this is supported in python.

By using the else we can add more info to the iteration which got missed in the loop and this also works as a final statement of loops.

Below is the output for the given program

output:

Inside the loop 0
Inside the loop 1
Inside the loop 2
Inside the loop 3
Inside the loop 4
Inside the loop 5
Inside the loop 6
Inside the loop 7
out of loop

Releases

No releases published

Packages

No packages published

Languages