← Python from Scratch
Lesson 30 of 78 · 5 XP
Warm-up: from 1 to n warm-up
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
range(1, n + 1) gives the numbers from 1 to n. The second number in range is not included, so we write n + 1:
for i in range(1, 4):
print(i) # 1, 2, 3
Task. Read a number n and print the numbers from 1 to n, each on its own line.
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.