Traceback (most recent call last): File "/piston/jobs/d0631b70-3713-4bed-b170-697fb882d0d4/test.py", line 5, in <module> n1=int(input())ValueError: invalid literal for int() with base 10: '12 30'
Question
Traceback (most recent call last): File "/piston/jobs/d0631b70-3713-4bed-b170-697fb882d0d4/test.py", line 5, in <module> n1=int(input())ValueError: invalid literal for int() with base 10: '12 30'
Solution
The error message you're seeing is a Python error. It's saying that the program is trying to convert a string to an integer, but the string is '12 30', which can't be converted directly to an integer because it contains a space.
Here's a step-by-step explanation:
-
The program is trying to execute the line
n1=int(input()). This line is asking for user input, and then trying to convert that input into an integer. -
You've entered '12 30'. Python tries to convert this string into an integer.
-
Python can't convert '12 30' into an integer because it's not a valid integer. An integer can't contain spaces.
To fix this error, you need to ensure that the input you're providing can be correctly converted into an integer. If you're trying to input two separate numbers, you might need to handle them separately, like this:
n1, n2 = map(int, input().split())
This line will split the input on spaces and try to convert each part into an integer separately.
Similar Questions
Traceback (most recent call last): File "/piston/jobs/aea0f700-51c4-48f4-b83d-0a1c37ad2b8b/test.py", line 8, in <module> n,m=map(int,input().split())ValueError: invalid literal for int() with base 10: '{{}}'1
24 23Traceback (most recent call last): File "/piston/jobs/09281298-42ab-4850-b2da-e6fc4d5a0ea3/test.py", line 9, in <module> hrs=D//pTypeError: unsupported operand type(s) for //: 'int' and 'function'36 32Traceback (most recent call last): File "/piston/jobs/5da139ac-bf93-4331-8eb2-a96e6fe8883a/test.py", line 9, in <module> hrs=D//pTypeError: unsupported operand type(s) for //: 'int' and 'function'
Traceback (most recent call last): File "/piston/jobs/22662a3d-72b6-423a-b219-4b778f327c41/test.py", line 14, in <module> c[i[0]-1]=i[1]IndexError: list assignment index out of range
Traceback (most recent call last): File "/piston/jobs/b4a38496-5fb5-4161-b994-1c959d5e0c10/test.py", line 3, in <module> a,b=map(int,input().split())ValueError: not enough values to unpack (expected 2, got 1)
Traceback (most recent call last): File "/piston/jobs/49640095-2ad6-4c8f-ab6b-80772c4d7bd6/test.py", line 45, in <module> root=insert(root,n) File "/piston/jobs/49640095-2ad6-4c8f-ab6b-80772c4d7bd6/test.py", line 12, in insert root.right=insert(root.right,data) File "/piston/jobs/49640095-2ad6-4c8f-ab6b-80772c4d7bd6/test.py", line 12, in insert root.right=insert(root.right,data) File "/piston/jobs/49640095-2ad6-4c8f-ab6b-80772c4d7bd6/test.py", line 12, in insert root.right=insert(root.right,data) [Previous line repeated 994 more times] File "/piston/jobs/49640095-2ad6-4c8f-ab6b-80772c4d7bd6/test.py", line 8, in insert root=node(data)RecursionError: maximum recursion depth exceeded
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.