ce
Back to Timeline
brightness_2
notifications
User
list
Details
Code
2. How a Coder Counts
by CodeChum Admin
Instructions:
Make a variable and assign it to an input() function that will accept an integer value. Make sure that the value is now holding a real integer and not just a default string, so make use of what you’ve learned on typecasting your input() functions on the past lessons.
Create a for loop that will print out numbers starting from 0 until the value of the inputted integer, each printed on separate lines. Make use of the range() function well in performing this task.
Instructions
Input
A line containing an integer.
10
Output
Multiple lines containing an integer.
1
2
3
4
5
6
7
8
9
10
n = int(input())
for i in range(n+1):
print(i)
Comments
Leave a comment