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 - If we want to ask the user for multiple values on a single line, we can use list comprehension combined with the input() function and split() to break the input into individual components.
🌐
DEV Community
dev.to › mohit355 › 3-5-split-method-in-python-2e19
3.5 split() method in Python - DEV Community
December 19, 2019 - x, y = input("Enter two value: ... code output is look like this · Enter two value:5 10 first value is :5 second value is :10 Enter two value:5,10 first value is :5 second value is :10 · We can also take a list as an input ...
Discussions

python - How can i use input().split() effectively to take at least 2 inputs from user in one line? - Stack Overflow
0 How do you obtain/split multiple string inputs in Python3 ... Who (if anyone) has argued that the disqualification in Article I, Section 3, Clause 7 of the US Constitution does not extend to the presidency? Cannot reproduce a Wolfram example of MissenseVariantPlot3D More on stackoverflow.com
🌐 stackoverflow.com
python - Using split on an input string - Stack Overflow
It's worth nothing that in the OP's question, the second example works and they are asking about the difference. The hardcoded list1 is using integer inputs and that's the main difference compared to the input method. Which takes a string and splits it into a list of strings 2020-02-19T16:57:05.087Z+00:00 ... Save this answer. ... Show activity on this post. Error in your code: you are trying to raise power before converting it to int ... Another approach, using map function. ... In python... More on stackoverflow.com
🌐 stackoverflow.com
Split an input into two. Python 3 - Stack Overflow
I've used this method before but can't find it in any of my codes so here I am on Stack Overflow :) What I'm trying to do is split an input into two( the user is asked to enter two digits separated... More on stackoverflow.com
🌐 stackoverflow.com
May 22, 2017
How to split user input in python?
For example : i want to split golden to 'g','o','l','d','e','n'.... THANK YOU! More on sololearn.com
🌐 sololearn.com
26
13
People also ask

Can the input to the split() function in Python only be a string?
Yes. Since it is a string method, split() can only be invoked on strings.
🌐
interviewkickstart.com
interviewkickstart.com › home › blogs › learn › the split() function in python
The split() Function in Python | Interview Kickstart
For the split() function in Python, what will the data type of the individual elements of the output array be?
The individual elements in the list will always be strings themselves.
🌐
interviewkickstart.com
interviewkickstart.com › home › blogs › learn › the split() function in python
The split() Function in Python | Interview Kickstart
Can the separator in Python's split() function be a number?
Yes and no. For example, the separator can't be the integer 2, but the separator can be the character "2". For example, "1232425262".split("2") will return ['1', '3', '4', '5', '6', '']
🌐
interviewkickstart.com
interviewkickstart.com › home › blogs › learn › the split() function in python
The split() Function in Python | Interview Kickstart
🌐
EyeHunts
tutorial.eyehunts.com › home › input split python | example code
Input split Python | Example code
July 20, 2023 - # number of elements n = int(input("Enter number of elements : ")) # Below line read inputs from user using map() function a = list(map(int, input("\nEnter the numbers : ").strip().split()))[:n] print("\nList is - ", a) ... Comment if you have any doubts or suggestions on this Python input program code. ... All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
🌐
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.
🌐
Interview Kickstart
interviewkickstart.com › home › blogs › learn › the split() function in python
The split() Function in Python | Interview Kickstart
December 20, 2024 - Q4. Can the separator in Python’s split() function be a number? Yes and no. For example, the separator can’t be the integer 2, but the separator can be the character “2”. For example, “1232425262”.split(“2″) will return [‘1’, ‘3’, ‘4’, ‘5’, ‘6’, ”].
🌐
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.
Find elsewhere
🌐
AskPython
askpython.com › python › string › python-string-split-function
Python String split() function - AskPython
January 9, 2020 - csv_input = input('Enter CSV Data\n') csv_output1 = csv_input.split(sep=',') print('\nList of inputs =', csv_output1) ... Python string split() function is very useful in splitting delimiter based values into a list of strings.
🌐
Hyperskill
hyperskill.org › university › python › split-in-python
Python split(): Split Strings by Delimiter with Examples
June 5, 2026 - 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() ...
Top answer
1 of 3
5

You might want to do exponentiation after converting to an int:

Use with AImylist = [int(i)**2 for i in list1]

You can't raise a string to a power (do you know what the square of the string "blah" is?), but you can raise a number to a power. So you need to convert the string to a number first.

Of course, a.split() returns a list of smaller strings derived from the original string, and you have to turn them into numbers yourself, but you already figured this out.

2 of 3
0

Error in your code: you are trying to raise power before converting it to int

Use with AIint(i**2) 
#should be 
int(i)**2

Another approach, using map function.

Syntax: map(func, iterable)

In python, String is iterable which means you can iterate over it. For example:

Use with AIfor i in "hello":
   print(i)

#output will be: 
    h
    e
    l
    l
    o

Another simple concept before moving to map function: split() function will return the list.

Use with AIprint(type("hello".split()))
#output will be
<class 'list'>

Lets use map function to answer your question:

Use with AIa = map(int, input('Enter three digits separated by space:').split())

mylist = [i**2 for i in a]
print(mylist)

Explanation:

  • The input() function will ask user to enter three numbers separated by space and that will be a string, now you can use split function over the string returned by input().
  • Here, split function will return a list.
  • Now, map function comes into the picture, it will take each element from the list returned at step 2 and map it to the function, in this case, it will map each element of the list to int.
  • Variable a is map object, and map object is iterable, so you can apply for loop or list comprehension(you used list comprehension) to get desired output
🌐
Upgrad
upgrad.com › home › blog › data science › python split() function: syntax, parameters, examples
Python Split() Function: Examples, Methods & Practical Tips
July 6, 2026 - If you want to split a string by a digit, you must provide that digit as a string character. For example, to split 'chapter1section2' by the digit 1, you would use 'chapter1section2'.split('1').
🌐
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.
🌐
Scaler
scaler.com › home › topics › how to take multiple input in python?
How to Take Multiple Input in Python? - Scaler Topics
March 30, 2024 - Code: Below code we are exploring how we can use the list comprehension along with implementing the split() function to feed multiple input in Python which lets us input values to variables in a single line. We have considered three scenarios where we are exploring the list comprehension methods in addition to the implementation of the split() function when we input two inputs, three input, and unlimited inputs ins a single line and obtain individual values getting assigned to each variable. ... Explanation: As seen in the above example, we have considered three scenarios where we implement the logic of list comprehension in addition to the implementation of the split() function that we just studied, where we input the values to variables in a single line as a multiple input in Python.
🌐
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 in a single line from the user, we use the ___ method in Python. ... When using the `input().split()` method, the default separator between inputs is ___.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-split
Python split() Method - GeeksforGeeks
July 1, 2026 - Explanation: s.split(',') splits the string s at every comma and returns a list of the parts ['one', 'two', 'three'].
🌐
Mimo
mimo.org › glossary › python › string-split-method
Learn Python's String Split Method, Simplify Text Processing
For example, extracting error messages might involve dictionaries to organize the structured information. Python · Open in MimoOpen in MimoCopy Code · log = "2024-05-17 10:00:00 ERROR Server down" parts = log.split() print(parts) # Outputs: ['2024-05-17', '10:00:00', 'ERROR', 'Server', 'down'] Interactive programs can split user input into commands or parameters.
🌐
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 = [int(x) for x in input().split()] print("Number of list is: ", x)43 12 34 67 09 653 2321 12 Number of list is: [43, 12, 34, 67, 9, 653, 2321, 12] The above examples take input separated by spaces.
🌐
YouTube
youtube.com › practical programmer
HOW TO RECEIVE USER INPUT IN PYTHON | SPLIT( ) | 2020 - YouTube
LEARN PYTHON EASILY.In this python tutorial, we will learn about how to receive user input using input function in python. We will take an example of user in...
Published: August 7, 2020
Views: 2K