How to generate a sequence of numbers in Python
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.
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)
It is often used with loops like that :
for each in range(0,10):
print(each)
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)
Here you are ! You now know how to generate a sequence of numbers in Python !
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.
Related Articles
Continue your learning journey with these related topics
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. 📚