Skip to content
Advertisement

How to pass empty string into integer in python?

i have one file which is highcore.txt and it is empty.

i want if txt file is empty or if any number which is score is greater than any number in txt file , update the txt file , here is my code

JavaScript

it is giving error

JavaScript

how to fix this error

Advertisement

Answer

I don’t think it is possible to pass an empty string through int()

Since you know it starts as an empty string you’re probably better off writing 2 if statements:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement