Turn this into bullet points Improved code with better variable names and error handling…
Jump to turn (9)
- User
Turn this into bullet points
Improved code with better variable names and error handling
escape_code = “” current_value = “” backup_value = “”
print(“Enter the escape code:”) escape_code = input()
def check_variable(escape_code): print(f"The current escape code is {escape_code}.“) print(“Would you like to update it? (Y/N)”) choice = input().upper() if choice == “Y”: print(“Enter the new escape code:”) escape_code = input() print(f"The escape code has been updated to {escape_code}.”) elif choice != “N”: print(“Invalid choice.”) escape_code = check_variable(escape_code)
return escape_code
def restore_backup(escape_code, backup_value): escape_code = backup_value print(f"The escape code has been restored to {escape_code}.") return escape_code
print(“Would you like to check/update the escape code or restore the backup? (U/R)”) choice = input().upper()
while choice == “U” or choice == “R”: if choice == “U”: backup_value = escape_code escape_code = check_variable(escape_code)
elif choice == “R”: escape_code = restore_backup(escape_code, backup_value)
print(“Would you like to check/update the escape code or restore the backup? (U/R)”) choice = input().upper()
print(“Exiting program.”)