I have two txt files. This files are created automatically and it also inserts '10' as a text into these files. But if the program reads the files it gives an error like "ValueError: invalid literal for int() with base 10: ''". How can i fix this error?
income_txta = open(("monthly_income,expences_amount\\income\\" + year + month + ".txt"), "a")
income_txtr = open(("monthly_income,expences_amount\\income\\" + year + month + ".txt"), "r")
if income_txtr.read() == '':
income_txta.write("10")
total_income=10
else:
total_income = int(income_txtr.read())
expences_txta = open(("monthly_income,expences_amount\\expences\\" + year + month + ".txt"), "a")
expences_txtr = open(("monthly_income,expences_amount\\expences\\" + year + month + ".txt"), "r")
if expences_txtr.read() == '':
expences_txta.write("10")
total_expences = 10
else:
total_expences = int(expences_txtr.read())
print(total_expences)