I am looking to correct this code so that when the user inputs 99999 then the code stops running, im also looking to make it so that if the user input is 999 it sets the total to 0
import sysdef money_earned():total = int()try: # try open the filefile = open("total.txt", "r") data = file.readline()total = int(data)except: # if file does not existfile = open("total.txt", "w+") # create filetotal = 0file.close() # close file for nowwhile True:try:pay_this_week = int(input("How much money did you earn this week? "))breakexcept ValueError:print("Oops! That was no valid number. Try again...")pay_this_week_message = "You've earned £{0} this week!".format(pay_this_week)total = pay_this_week + totaltotal_message = "You have earned £{0} in total!".format(total)print(pay_this_week_message)print(total_message)if pay_this_week == "99999":sys.exit()file = open("total.txt", "w") # wipe the file and let us write to itfile.write(str(total)) # write the datafile.close() # close the filemoney_earned()