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 OverflowGeeksforGeeks
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.
08:04
🐍 Python Tutorial #27: Splitting and Joining Strings - YouTube
Input a List using split() Method and Loops in Python
10:24
Reading multiple inputs in single line | .split() | python tutorial ...
01:50
Split Method in Python - Use Case - YouTube
How to take multiple inputs in Python | Python Tutorial | split() ...
Reddit
reddit.com › r/learnpython › what does list(map(int,input().split())) do in python?
r/learnpython on Reddit: What does list(map(int,input().split())) do in python?
September 15, 2020 -
What does list(map(int,input().split())) do in python? Can please anyone explain what this line does.
Top answer 1 of 4
29
Let's break it down: input() gets user input and returns a string, e.g. "1 2 3 4 5" input().split() splits that input on whitespaces, e.g. ["1", "2", "3", ...] int() converts a string to a integer, e.g. "1" -> 1 map(fn, sequence) applies the function fn to each element in the sequence, e.g. fn(sequence[0]), fn(sequence[1]), ... map(int, input().split()) applies int to each string element in the input, e.g. ["1", "2", "3", ...] -> int("1"), int("2"), ... list() turns any iterator/generator to a list, e.g. int("1"), int("2"), ... => [1, 2, 3, ...] Example: In []: list(map(int, input().split())) Input: 1 2 3 4 5 Out[]: [1, 2, 3, 4, 5] Note: this is the same as, which may be easier to read: In []: [int(n) for n in input().split()] Input: 1 2 3 4 5 Out[]: [1, 2, 3, 4, 5]
2 of 4
9
There are already two correct answers here! A nicer way to do it is [int(i) for i in input.split()]. Isn't that more obvious? Generally, map should nearly always be replaced by a list comprehension or a generator.
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.
W3Schools
w3schools.com › python › ref_string_split.asp
Python String split() Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... The split() method splits a string into a list.
YouTube
youtube.com › watch
Input a List using split() Method in Python - YouTube
Python Programming: Input a List using split() Method in PythonTopics discussed:1. Rivising the split() Method.2. Input a List using the split() Method. Pyth...
Published: August 1, 2023
Hyperskill
hyperskill.org › university › python › split-in-python
Python split(): Split Strings by Delimiter with Examples
June 5, 2026 - To use the split() function, provide the delimiter as an argument within the parentheses. The delimiter can be any character or substring that you want to use as a separator. The function searches for occurrences of the delimiter within the string and breaks it down at each occurrence. # Using whitespace as a delimiter text = "Hello World! Welcome to Python!" result = text.split() print(result) # Output: ['Hello', 'World!', 'Welcome', 'to', 'Python!'] # Using a comma as a delimiter fruits = "apple,banana,orange" result = fruits.split(",") print(result) # Output: ['apple', 'banana', 'orange']
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 - Well, we learned how to take multiple inputs from users in a single line of Python code instead of writing multiple lines of code. 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.
GitHub
github.com › zhiwehu › Python-programming-exercises › blob › master › 100+ Python challenging programming exercises for Python 3.md
Python-programming-exercises/100+ Python challenging programming exercises for Python 3.md at master · zhiwehu/Python-programming-exercises
Suppose the following input is supplied to the program: New to Python or choosing between Python 2 and Python 3? Read Python 2 or Python 3. Then, the output should be: 2:2 3.:1 3?:1 New:1 Python:5 Read:1 and:1 between:1 choosing:1 or:2 to:1 · Hints In case of input data being supplied to the question, it should be assumed to be a console input. ... freq = {} # frequency of words in text line = input() for word in line.split(): freq[word] = freq.get(word,0)+1 words = freq.keys() words.sort() for w in words: print("%s:%d" % (w,freq[w]))
Jinja
jinja.palletsprojects.com › en › stable › templates
Template Designer Documentation — Jinja Documentation (3.1.x)
A template contains variables and/or expressions, which get replaced with values when a template is rendered; and tags, which control the logic of the template. The template syntax is heavily inspired by Django and Python.
GeeksforGeeks
geeksforgeeks.org › python › input-and-output-in-python
Input and Output in Python - GeeksforGeeks
x, y = input("Enter two numbers: ").split() print(x , y) Output · Enter two numbers: 10 20 10 20 · We can change the user input from default string type to any other type (int, float, etc) by typecasting. Python · i = int(input("How old are you?: ")) f = float(input("Evaluate 7/2: ")) print(i, f) Output ·
Published: September 19, 2026
Programiz
programiz.com › python-programming › methods › string › split
Python String split() | Programiz
February 21, 2024 - The split() method returns a list of strings.