top of page
Search
Writer's pictureAbhinaw Tripathi

break and continue in python


So break and continue theoretically same as other programming language.taking a small example to demonstrate both in Python. break example: student_names = ["james" ,"Mark", "Abhinaw", "Arudhra" ,"Rajat", "Gaurav"] for name in student_names: if name == "Arudhra": print("Found him!" + name) break print("Currently testing " + name) Output: Currently testing james Currently testing Marks Currently testing Abhinaw Found her! Arudhra continue example: student_names = ["james" ,"Mark", "Abhinaw", "Arudhra" ,"Rajat", "Gaurav"] for name in student_names: if name == "Arudhra": print("Found him!" + name) continue print("Currently testing " + name) Output: Currently testing james Currently testing Marks Currently testing Abhinaw Currently testing Rajat Currently testing Gaurav we see that except for Arudhra .it print all names. 


4 views0 comments

Recent Posts

See All

Lambda Functions in Python

So Lambda Functions are just an anonymous function.they are very simple just saves your space and time.they are useful in case of higher ...

bottom of page