Data Science Micro
Published in

Data Science Micro

Loop control: break, continue, pass

There are 3 so-called loop control keywords: break, continue and pass.

Break

If a break statement is present in the loop, it terminates the loop when a condition is satisfied.

string = 'hello, there'for i in string:
if i == ',':
break
print(i)
>>
h
e
l
l
o

In the snippet above, we ask the program to exist as soon as it finds a comma in a string and executes the next statement (which is to print i).

This publication will publish brief articles on data science theory, algorithms, tools and applications.

Recommended from Medium

How to add class variables to a python class programmatically?

The Bistroo Breakdown: Monthly Progress Report — November 2020

The Bistroo Breakdown cover for November 2020

Day 1 of 30-Day LeetCode Challenge

DeckDeckGo: Why building presentation with web standards makes sense?

Why do I like coding?

DevSecOps Toolbox: MFA

Kotlin Unpacking Params

What do we know about GeForce RTX 30 series?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mahbubul Alam

Mahbubul Alam

Data scientist, economist. Twitter @DataEnthus / www.linkedin.com/in/mab-alam/

More from Medium

Use Python’s itertools built-in module to create a decaying sine wave

Mastering Pandas — Part 1: Installation And Overview Pandas

SQL Connection in Julia

Funky Python things you might have not thought about