Write a programme to input a no. and display all the natural no. till the number taken as input.
Answers
To make this possible, we will take the input from the user and use the range function to take care of the other part of this function that is printing the natural numbers until an end point.
The syntax for the range() function is simple,
range(x,y) -- x is the start position and y is the end position but while printing, y is not accounted.
For example, if we have range(1,3) : The output would be 1 and 2. The start and between would be accounted for but not the end.
CODE:
number = int(input())
for natural_number in range(1,number+1):
print(natural_number)
____________________
Because we need to print natural numbers and natural number start with 1, we use the start point as 1 and as we need to include the number in our input, we will have to add 1 to the end for the number to be printed on the screen.