Reputation: 3370
First and foremost: I'm using Ubuntu 22.04 and Python 3.10.4.
Suddenly my PyCharm IDE is showing me a inexplicable ValueError
when I run the script.
A code as simple as bellow return a value error on line 2
a = int(input())
b = int(input())
print(f'{a + b}')
My input:
1
1
The error:
Traceback (most recent call last):
File "/home/user/sample/Python/main.py", line 2, in <module>
b = int(input())
ValueError: invalid literal for int() with base 10: ''
Funny enough, if I type anything inside the input()
function at line 2, the code works:
a = int(input())
b = int(input("Second number: "))
print(f'{a + b}')
Result:
1
Second number: 1
2
Process finished with exit code 0
Video of the actual behavior:
Can someone explain what is going on here?
Upvotes: 2
Views: 307