Feb. 20, 2024, 10:57 p.m. | Paulo GP

DEV Community dev.to




Introduction

In this chapter, we'll explore the use of for and while loops in Python. We'll start by showing how to create a loop using the range function, which allows us to iterate over a sequence of numbers. For example, we can use range to create a loop that prints the numbers 1 to 10:



for i in range(1, 11):
print(i)



Output:
1
2
3
4
5
6
7
8
9
10





Using Range with Specific Intervals

We can also …

beginners example explore function guide introduction iterate loop numbers programming python

Lead Developer (AI)

@ Cere Network | San Francisco, US

Research Engineer

@ Allora Labs | Remote

Ecosystem Manager

@ Allora Labs | Remote

Founding AI Engineer, Agents

@ Occam AI | New York

AI Engineer Intern, Agents

@ Occam AI | US

AI Research Scientist

@ Vara | Berlin, Germany and Remote