I'm getting this error in my code:
ValueError: invalid literal for int() with base 10: ''.
What does it mean? Why does this happen and how to solve it?
This error message means that the string supplied to int cannot be parsed as an integer. The last part after : displays the provided string.
int
:
In the case of the problem description, the input is an empty string , written as ''.
''
Here's another example - strings representing floating point values cannot be converted directly with int:
>>> int('55063.000000') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '55063.000000'
Instead, first convert to float:
float
>>> int(float('55063.000000')) 55063
This error message means that the string supplied to
int
cannot be parsed as an integer. The last part after:
displays the provided string.In the case of the problem description, the input is an empty string , written as
''
.Here's another example - strings representing floating point values cannot be converted directly with
int
:Instead, first convert to
float
: