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
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.
Comments