The input() function takes keyboard input from the console. The input() function accepts keyboard input data and returns a string type.
If you encounter code within the acient Python2.x, it had the method raw_input(). That doesn’t exist anymore, so use input() method.
Related Course: Complete Python Programming Course & Exercises
Python input() example.
get string from terminal
The input function returns a string by default, so by calling it you get a text object.
Anything returned is of string type (type str).
>>> name = input("Your name: ")
Your name: Sida
>>> type(name)
<class 'str'>
>>> print(name)
Sida
>>>
get integer from console
The input() function takes keyboard input from the console and returns a string (any data is of type string). To read an integer from the console, you have to cast it:
>>> a = input("i: ")
i: 6
>>> a
'6'
>>> type(a)
<class 'str'>
>>>
Type str, so if you want an integer, you cast it by calling int():
>>> a = int(input("i: "))
i: 256
>>> type(a)
<class 'int'>

python input list
The input() function can be used to take a list as input. Take a string as input as you’d normally do, then split it based on the delimiter (like a comma).
>>> x = input()
1,2,3,4,5,6
# convert input string into list of strings
>>> xlist = x.split(",")
# output list
>>> xlist
['1', '2', '3', '4', '5', '6']
>>>
But everything is over character value (string), you can see that on the quotes. To convert it to int values, you can do this:
>>> xlist = [int(xlist[i]) for i in range(len(xlist))] #for loop, convert each character to int value
>>> xlist
[1, 2, 3, 4, 5, 6]
>>>
The parameters of the split() function can be any delimiter, including (a,b,c...); 1,2,3... ;1,2,3... ;%,! ,*, space) >>> x=input()
1 2 3 4
# split into list of strings
>>> xlist=x.split(" ")
# show what you have
>>> print(xlist)
['1', '2', '3', '4']
# convert to numbers
>>> xlist = [int(xlist[i]) for i in range(len(xlist))]
>>> print(xlist)
[1, 2, 3, 4]
Related Course: Complete Python Programming Course & Exercises
