top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Python break and continue statements

Writer's picture: Kala Maya SanyasiKala Maya Sanyasi

The break and continue statements in python alters the flow of a normal loop.

Example of break state is illustrated below.

Here the program iterates through 'python' sequence, checks the letter 't', when 't' is encountered it breaks from the loop. The letters up till 't' gets printed, after that the loop terminates.

#break statement
#terminates the loop containing it
for val in 'python':
    if val == 't':
        break
    print(val)
print('end')
p
y
end

Example of continue statement.

continue statement is used to skip an iteration. Here the program iterates through 'python' sequence, checks for the letter 't', and when 't' is met it skips the letter 't' and continues the loop until the end.

#continue statement
#skips the loop containing it
for val in 'python':
    if val == 't':
        continue
    print(val)
print('end')
p
y
h
o
n
end




0 comments

Recent Posts

See All

Comments


COURSES, PROGRAMS & CERTIFICATIONS

 

Advanced Business Analytics Specialization

Applied Data Science with Python (University of Michigan)

Data Analyst Professional Certificate (IBM)

Data Science Professional Certificate (IBM)

Data Science Specialization (John Hopkins University)

Data Science with Python Certification Training 

Data Scientist Career Path

Data Scientist Nano Degree Program

Data Scientist Program

Deep Learning Specialization

Machine Learning Course (Andrew Ng @ Stanford)

Machine Learning, Data Science and Deep Learning

Machine Learning Specialization (University of Washington)

Master Python for Data Science

Mathematics for Machine Learning (Imperial College London)

Programming with Python

Python for Everybody Specialization (University of Michigan)

Python Machine Learning Certification Training

Reinforcement Learning Specialization (University of Alberta)

Join our mailing list

Data Insight participates in affiliate programs and may sometimes get a commission through purchases made through our links without any additional cost to our visitors.

bottom of page