In your example you probably typed just one number on the line, and the error was raised because you expect 2 (a and b)

You should type both numbers on the same line, then enter.

You can change your code to accept any number of numbers, and store them in a list:

res = input("Enter your numbers:").split()
print(*res)   ## prints the list content
for r in res: ## prints number one by one and one per line
    print(r)

result:

Enter your numbers: 12 13 14
12 13 14
12
13
14
Answer from Malo on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ taking-multiple-inputs-from-user-in-python
Taking multiple inputs from user in Python - GeeksforGeeks
June 26, 2026 - One of the simplest ways to take multiple inputs from a user in Python is by using the input() function along with the split() method.
Discussions

How to take more inputs from a user at the same time in Python?
The split() method will generate a list. number_list = input("Please input multiple integers separated by commas: ").split(',') Note that this will generate a list of strings. If you want to convert them to integers for later use, you'll need another step. More on reddit.com
๐ŸŒ r/learnpython
5
1
February 16, 2023
Using split(): method in Python 3 to get multiple inputs - Stack Overflow
I am working on a project where I need to implement code that will ask the user for multiple data inputs for the following fields for an employee directory: Last name, first name, employee number, ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
February 23, 2015
Taking multiple integers on the same line as input from the user in python - Stack Overflow
In Python 2, you can input multiple values comma separately (as jcfollower mention in his solution). But if you want to do it explicitly, you can proceed in following way. I am taking multiple inputs from users using a for loop and keeping them in items list by splitting with ','. More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to take either multiple or single input on one line from Python - Stack Overflow
To accept multiple inputs on one line, I know you can do something like: a, b = input().split() And if the user were to only type 1 input, they would come across a ValueError: "ValueError: not More on stackoverflow.com
๐ŸŒ stackoverflow.com
People also ask

What is the role of split() in taking multiple inputs in Python?
split() divides a string into individual elements based on a delimiter, usually a space. It allows you to take multiple inputs in Python in one line and store them in a list for further processing.
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ blog โ€บ data science โ€บ how to take multiple inputs in python: techniques and best practices
Multiple Input in Python: Techniques, Loops & Best Practices
How do you take multiple inputs from a file in Python?
Use the open() function or the fileinput module to read lines from a file. You can then process each line and convert values to integers, floats, or strings. This is a practical way to handle multiple inputs in Python from external files.
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ blog โ€บ data science โ€บ how to take multiple inputs in python: techniques and best practices
Multiple Input in Python: Techniques, Loops & Best Practices
How do you unpack multiple inputs into separate variables in Python?
If the number of inputs is fixed, you can unpack them directly: a, b, c = map(int, input().split()). Each input is assigned to a variable, making it easy to work with multiple inputs in Python without manually indexing a list.
๐ŸŒ
upgrad.com
upgrad.com โ€บ home โ€บ blog โ€บ data science โ€บ how to take multiple inputs in python: techniques and best practices
Multiple Input in Python: Techniques, Loops & Best Practices
๐ŸŒ
Medium
geekpython.medium.com โ€บ take-multiple-inputs-from-users-in-one-line-using-python-7c7594237f5a
Take Multiple Inputs From Users In One Line Using Python | by Sachin Pal | Medium
December 11, 2022 - We used the split() method which is primarily used for splitting the Python string into a list and then we used the list comprehension technique which offers a shorter syntax to define and create a list in Python.
๐ŸŒ
DEV Community
dev.to โ€บ mohit355 โ€บ 3-5-split-method-in-python-2e19
3.5 split() method in Python - DEV Community
December 19, 2019 - grocery = 'Milk, Chicken, Bread, Butter' print(grocery.split(', ', 2)) print(grocery.split(', ', 1)) print(grocery.split(', ', 0)) print(grocery.split(', ', 5)) ['Milk', 'Chicken', 'Bread, Butter'] ['Milk', 'Chicken, Bread, Butter'] ['Milk, Chicken, Bread, Butter'] ['Milk', 'Chicken', 'Bread', 'Butter'] Developer often wants a user to enter multiple values or inputs in one line. In C++/C user can take multiple inputs in one line using scanf but in Python user can take multiple values or inputs in one line by two methods.
๐ŸŒ
Upgrad
upgrad.com โ€บ home โ€บ blog โ€บ data science โ€บ how to take multiple inputs in python: techniques and best practices
Multiple Input in Python: Techniques, Loops & Best Practices
July 7, 2026 - Here are the most common ways to take multiple inputs in Python: ... split() function separates the values entered by the user based on spaces (default) or another delimiter you specify.
๐ŸŒ
IncludeHelp
includehelp.com โ€บ python โ€บ taking-multiple-inputs-from-the-user-using-split-method.aspx
Taking multiple inputs from user in Python
To take multiple inputs from the user in Python, you can simply use the combination of input() and split() method like input().split() and write the multiple values as input with separators/delimiters.
Find elsewhere
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ how to take multiple input in python?
How to Take Multiple Input in Python? - Scaler Topics
March 30, 2024 - To give multiple input in Python, the split() function in Python helps to split the multiple input fed by the user into single individual values for each variable. The method takes two parameters as part of its syntax that is, the separator and the maxsplit. When we input values in a single ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ input-multiple-values-user-one-line-python
How to input multiple values from user in one line in Python? - GeeksforGeeks
April 20, 2025 - Explanation: input().split() reads ... each value separately using a loop. It is very inefficient for large inputs and should generally be avoided unless you want to handle inputs one by one....
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ taking-multiple-inputs-from-user-in-python
Taking multiple inputs from user in Python
July 11, 2020 - # taking the input from the user numbers = input("Enter multiple numbers space-separated:- ") # splitting the data and converting each string number to int numbers = list(map(int, numbers.split())) # printing the data print(numbers)
๐ŸŒ
Plain English
plainenglish.io โ€บ home โ€บ blog โ€บ python โ€บ how to take multiple inputs from users in python
How to Take Multiple Inputs From Users In Python
July 11, 2021 - x= input("Enter variables: ").split(",") print(x) Enter variables: how,are,you,dear ['how', 'are', 'you', 'dear'] Taking multiple inputs at a time and type casting using list() function.
๐ŸŒ
Recenturesoft
recenturesoft.com โ€บ taking-multiple-inputs-from-user-in-python
How to take Multiple Inputs in Python? 100% working tips | Recenturesoft
In this example, we will take two inputs from the user and then print them. num = list(map(int, input("Enter a multiple value: ").split())) print("List of students: ", num) We can use this method to take multiple inputs in Python from the user. This is generally used when we want input for a list.
๐ŸŒ
StudySmarter
studysmarter.co.uk โ€บ python multi input
Python Multi Input: Techniques & Examples | StudySmarter
One of the simplest and most effective ways to capture multiple inputs is by using the input() function combined with split(). This method splits a single input string into separate components, which can be processed individually or collectively. Imagine asking users to enter their names, ages, ...
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 28665527 โ€บ using-split-method-in-python-3-to-get-multiple-inputs
Using split(): method in Python 3 to get multiple inputs - Stack Overflow
February 23, 2015 - I am working on a project where I need to implement code that will ask the user for multiple data inputs for the following fields for an employee directory: Last name, first name, employee number, and pay rate. ... user_input = input("enter last name, first name, employee number, and pay rate: ") a = user_input.split() print (a[0]) # last name print (a[1]) # first name print (a[2]) # employee number print (a[3]) # pay rate
๐ŸŒ
Medium
kkbhoyar.medium.com โ€บ inputting-with-python-input-statement-for-beginners-8933b4fa37c6
Inputting with Python input statement for Beginners | by Dr. Kishor Bhoyar | Medium
July 26, 2020 - An iterable is any Python object ... element of the given iterable. The split() function separates input line entered by the user into a list of different tokens separated by the given separator....
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 73601515 โ€บ how-to-take-either-multiple-or-single-input-on-one-line-from-python
How to take either multiple or single input on one line from Python - Stack Overflow
a, *b = input().split() print(f'first variable is {a}') print(f'there is {"a" if b else "no"} second variable') if b: print(f'second variable is {b[0]}')
๐ŸŒ
CodeChef
codechef.com โ€บ learn โ€บ course โ€บ python โ€บ LTCPY10 โ€บ problems โ€บ PYTHCL50C
Multiple string inputs in Python Programming
Test your Learn Python Programming knowledge with our Multiple string inputs practice problem. Dive into the world of python challenges at CodeChef.
๐ŸŒ
Quora
quora.com โ€บ How-do-I-take-multiple-inputs-in-one-line-in-Python-programming-x-y-map-int-input-split-This-does-not-work-for-inputs-of-more-than-two
How do I take multiple inputs in one line in Python programming (x,y=map (int, input().split())? This does not work for inputs of more th...
Answer: well you can use [code]x,*y=map(int, input().split()) [/code]you can have multiple inputs in one line but only first is allocated to x and rest all are allocated to y as list, so you can have as many input you want.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ input-and-output-in-python
Input and Output in Python - GeeksforGeeks
Python ยท s = "Brad" print(s) s ... splitting the values entered by the user into separate variables for each value using the split() method: Python ยท...
Published: September 19, 2026