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 order function.Lets take an example: def double(a): r

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 read_students(f):

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: students =[] def get_students_titlecase():        students_titl

bottom of page