top of page
Search

break and continue in python

  • Writer: Abhinaw Tripathi
    Abhinaw Tripathi
  • Dec 15, 2017
  • 1 min read

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. 


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 ...

 
 
 
Generator Function - Yield Python

So Yield is a keyword.first let's take an example. student = [] def read_file(): try: f=open("students.txt","r") for student in...

 
 
 
Opening,Reading and Writing Python

Let's save our data in a file and read from that file again when we re-open our app. So let's take an example: Let's take an example: ...

 
 
 

Comments


© 2016 by Abhinav Tripathi

  • Facebook Clean Grey
  • Twitter Clean Grey
bottom of page