0

How to take input for a list in python such that the user will input it as [1,2,3] on the screen.

21st May 2020, 5:01 PM
Ankita Kumari
Ankita Kumari - avatar
4 Answers
+ 1
x= [] #here x is an empty list for i in range(0,3): #this will accept 3 values n=eval(input("Enter no.")) #user will enter 1,2,3 one by one x.append(n) #values will be added to empty list print(x)
22nd May 2020, 4:46 AM
Vaishnavi Rajkumar Pawar
0
Lst[] n=int(input("enter no. of terms ")) for i in range(0,n): x=int(input()) Lst.append(x) print (Lst)
21st May 2020, 10:20 PM
Vijay Raj Jain
- 1
Square brackets are mandatory while providing input else it will consider input as Tuple.
21st May 2020, 5:48 PM
Nag