Lesson 10: Loops: Repeating Without Retyping

One loop prints the numbers 1 up to your number. In the lesson, range(1, 6) gives 1 to 5; here the end is your number + 1, so the loop stops at your number. Change the number and run again.

Loading Python… this can take a few seconds the first time. Please wait — the Run button will become available when Python is ready.

Try this: Change the number to 3 and press Run again — only 1, 2 and 3 print.

The code that runs



Output

Press Run to see the output here.