How to generate a sequence of numbers in Python

7-Day Challenge

Land Your First Data Science Job

A proven roadmap to prepare for $75K+ entry-level data roles. Perfect for Data Scientist ready to level up their career.

Build portfolios that hiring managers love
Master the Python and SQL essentials to be industry-ready
Practice with real interview questions from tech companies
Access to the $100k/y Data Scientist Cheatsheet

Join thousands of developers who transformed their careers through our challenge. Unsubscribe anytime.

It is often useful to have a sequence of numbers in Python.

Using the built-in range() method your can generate a sequence of numbers.

numbers = range(0,10)

print(numbers)
How to generate and print a sequence of number in Python

It is often used with loops like that :

for each in range(0,10):
	print(each)
How to print each value of the sequence

Adding steps

You can also add a step value, so that it doesn't increment by one but by the step value.

Here is an example

numbers = range(0,100, 20)

print(numbers)
How to increment by more than 1 each time using the step value

Here you are ! You now know how to generate a sequence of numbers in Python !

7-Day Challenge

Land Your First Data Science Job

A proven roadmap to prepare for $75K+ entry-level data roles. Perfect for Data Scientist ready to level up their career.

Build portfolios that hiring managers love
Master the Python and SQL essentials to be industry-ready
Practice with real interview questions from tech companies
Access to the $100k/y Data Scientist Cheatsheet

Join thousands of developers who transformed their careers through our challenge. Unsubscribe anytime.

Free Newsletter

Master Data Science in Days, Not Months 🚀

Skip the theoretical rabbit holes. Get practical data science skills delivered in bite-sized lessons – Approach used by real data scientist. Not bookworms. 📚

Weekly simple and practical lessons
Access to ready to use code examples
Skip the math, focus on results
Learn while drinking your coffee

By subscribing, you agree to receive our newsletter. You can unsubscribe at any time.