Function returns invalid literal for int() with base 10: ''

Kira Vergil

I have a function, that parses string and takes values by using indexes. When I try to take the exact variable and convert it into integer, it gives me a ValueError. The exact code part is:

y = special_string[y_start:y_end]
print(y)
y = int(y)

Traceback for it:

14

Traceback (most recent call last):
  File "levelBuilder.py", line 255, in <module>
    newLevel, rows, columns = importLevel(levelName)
  File "levelBuilder.py", line 124, in importLevel
    y = int(y)
ValueError: invalid literal for int() with base 10: ''

The question is - what can cause this error? As you see, y is integer (14). When I use the same method for another variable (x), it works correctly

Wu Wenter

14

Traceback (most recent call last): File "levelBuilder.py", line 255, in newLevel, rows, columns = importLevel(levelName)

It looks like there is a space line between the "exception message" and "14". So, the y is ' ' , print(y) will print space line. int(y) will raise value err. Maybe be you should remove the '*pyc' file and retry :-)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Invalid literal for Int() base 10

Exception: invalid literal for int() with base 10: ''

ValueError: invalid literal for int with base 10: ' '

django urls() invalid literal for int() with base 10:

Python invalid literal for int() with base 10: '.'

ValueError: invalid literal for int() with base 10: '0.5'

invalid literal for int() with base 10: 'string name'

Django invalid literal for int() with base 10: 'Stalone'

Error: ValueError: invalid literal for int() with base 10

Python: "ValueError: invalid literal for int() with base 10:"

"ValueError: invalid literal for int() with base 10:"

ValueError: invalid literal for int() with base 10: '' (Tkinter)

invalid literal for int() with base 10: 'Requires moderation'

ValueError: invalid literal for int() with base 10: 'pippi'

ValueError: invalid literal for int() with base 10: 'quit'

ValueError invalid literal for int() with base 10: ''

pandas ValueError: invalid literal for int() with base 10: ''

Django invalid literal for int() with base 10

ValueError: invalid literal for int() with base 10?

invalid literal for int() with base 10: '3906.00'

Python: ValueError: invalid literal for int() with base 10: ' '

ValueError: invalid literal for int () with base 10

Python input invalid literal for int() with base 10

sqlalchemy invalid literal for int() with base 10

reason of exception invalid literal for int() with base 10:

Invalid literal for int() with base10

invalid literal for int() with base 10 Python

Django: ValueError: invalid literal for int() with base 10:

ValueError:invalid literal for int() with base 10:' '