0

enter image description here

here is my code

a = int(input())
b = int(input())

print(a, b)

and run result is here.

C:\PycharmProjects\venv\Scripts\python.exe C:/PycharmProjects/main.py
1
10
Traceback (most recent call last):
  File "C:\PycharmProjects\main.py", line 2, in <module>
    b = int(input())
ValueError: invalid literal for int() with base 10: ''

Process finished with exit code 1

i just input 5(enter)10 but error has occurred

in debug mode, it is OK Why occur ValueError in code?? please refer to attached picture also. thanks..!!

4
  • Looks like a problem with input in PyCharm. If you ran this code in a terminal it would work fine. Commented May 29, 2022 at 9:19
  • Looking again, it appears that somehow / somewhere the input function is getting an empty string, which is throwing the error when being converted to an int. Test this with int(''), which throws the same error. Commented May 29, 2022 at 9:21
  • @S3DEV like this? a = int('') b = int('') print(a, b) C:\PycharmProjects\venv\Scripts\python.exe C:/PycharmProjects/main.py Traceback (most recent call last): File "C:\PycharmProjects\main.py", line 1, in <module> a = int('') ValueError: invalid literal for int() with base 10: '' Process finished with exit code 1 Commented May 29, 2022 at 9:36
  • @khelwood Yes, it is success in terminal. Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> a = int(input()) 5 >>> b = int(input()) 10 >>> print(a,b) 5 10 >>> Commented May 29, 2022 at 9:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.