+ 1
How can i take input of a list in python?
What would be the code to take a list as input?
3 Answers
+ 4
lst = input().split() #String list
lst = list(map(int, input().split())) #Integer list
+ 2
Me as a complete beginner in Python will do something like this and the type can be changed by prepending the required type before the input().
Just an example-
newList = []
for i in range(5):
x = input()
newList.append(x)
print(newList)
+ 2
list=eval(input("Enter list :"))
#Input:[4,5,6,"hello"]