Python gives us freedom to take the input from the user. The input we take from the user is read as string by default. After giving input we have to press “Enter”. Then only the input() function reads the value entered by the user.
We can take more than one input in one line also. There are some methods by which we can do that.
Here we’ll see this by using examples.
- split()- This function is used to take more than one input in a single line.
x, y=input("Enter the number:").split() print(x, y)
- map()- This is also used to take more than one input in a single line()
x, y=map(int, input("Enter the number:").split()) print(x, y)
- input()- We can write more than one input function in a single line to make our program small.
x, y= input("Enter the first number:"), input("enter the second number:") print(x, y)
This is all about taking space generated integer input in python 3.