How to Take Input List From User in Python

To take input a list in python; Through this tutorial, i am going to show you how to take input a list from user in python using for loop.

Python Program to Take Input List From User in Python

Use the following steps to take input list or list of elements from user in python program; as shown below:

  • To define list in python program.
  • Take Input a limit for list of elements from the user.
  • Use for loop to take a single input number from the user.
  • Use list.append() to add elements in python list.
  • Print the list using for loop.
# Python Program to input, append and print the list elements
# declare a list
myList = []
# take number from user, how many element in list
n = int (input ("How many element in list :- "))
# append element into list using list.append
for i in range (n) :
	storeElement = int (input ("Enter an integer num :- "))
	myList.append (storeElement)
# print all elements
print("Input list elements are: ")
for i in range (n) :
	print(myList [i])

After executing a the program, the output will be:

How many element in list :-  4
Enter an integer num :-  1
Enter an integer num :-  2
Enter an integer num :-  3
Enter an integer num :-  4
Input list elements are: 
1
2
3
4

Recommended Python Tutorials

Leave a Comment