List from input

Report a typo

Use the template below to write a program that creates a list from user input and then prints it:

  • First, read an integer n. This number tells you how many numbers you need to read next in a loop;

  • Then read n integers, one per line, and store each number in a list;

  • Finally, print the list.

At this point, you may not know how to add elements to a list. You can use the command list.append(element) to do that, where list is the name of your list, and element is the name of the variable that you want to add to the list. Also, the pass statement is just a placeholder for your code, so you can safely replace it.

Sample Input 1:

5
100
-1
72
0
0

Sample Output 1:

[100, -1, 72, 0, 0]
Write a program in Python 3
n = int(input())
for i in range(n):
pass

Create a free account to access the full topic