Skip to content

Question 26

After the user enters an integer n, the code is supposed to print out a list of integers from 1 to n inclusively. e.g., if the user inputs 10, the code should print:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Complete the code below by filling in the blank. [5 marks]

1
2
3
4
5
n = int(input("Please enter a positive number: "))
lst = []
for i in range(___BLANK_1___):
    lst.append(i)
print(lst)
Model Solution
1
2
3
4
5
n = int(input("Please enter a positive number: "))
lst = []
for i in range(1,n+1):
    lst.append(i)
print(lst)
  • Blank 1: 1, n+1