Turn this into funny build 1923847. Improved code with better variable names and error…
- User
Turn this into funny build 1923847.
Improved code with better variable names and error handling
escape_code = '' current_value = '' backup_value = ''
print('What.') print('Is.') print('This.') print('You have to escape. Type this thingy.')
Prompt user to enter escape code
escape_code = input("Enter escape code: ") print("You have set the code to: ", escape_code)
Function to check and update variable
def check_variable(): global escape_code current_value = escape_code print(“Current value of variable:”, current_value) action = input("Do you want to change ©, backup (B), remove ®, or keep (K) this variable? ") while action not in ['C', 'B', 'R', 'K']: print('Invalid input. Please enter C, B, R, or K.') action = input("Do you want to change ©, backup (B), remove ®, or keep (K) this variable? ") if action == 'C': new_value = input("Enter the new value: ") print('Variable has been changed to:', new_value) escape_code = new_value return new_value elif action == "B": backup_value = escape_code print('Variable has been backed up to:', backup_value) return None elif action == 'R': print('Variable has been removed.') escape_code = '' return None elif action == 'K': print('Variable has been kept.') return escape_code
Function to restore backup value
def restore_backup(): global escape_code, current_value, backup_value escape_code = backup_value print('Variable has been restored from backup.')
Prompt user to check and update variable or restore backup
while True: answer = input('Type Y to check or update variable, or B to restore backup.') if answer == 'Y': check_variable() elif answer == 'B': restore_backup()
- Assistant
Welcome to the ultimate escape room simulation!
In this challenge, you must escape by typing in the secret escape code. But don't worry, we've improved the code with better variable names and error handling.
To begin, say "What."
"What."
"Is."
"This."
You have to escape. Type this thingy."
cue dramatic music
Now, to enter the escape code, simply type in the code and hit enter.
Escape Code: 1923847
Congratulations! You've set the code to 1923847. But wait, there's a catch!
You must now decide whether to change, backup, remove or keep the variable. Type in C, B, R or K respectively.
If you choose C, you can enter a new value for the variable. But be careful, one wrong move and the whole escape falls apart!
If you choose B, you'll backup the variable. If you choose R, you'll remove the variable. And if you choose K, you'll keep the variable as is.
cue intense countdown music
But wait, there's more! You can also choose to restore the backup value if you mess up. Just type in B.
So, are you ready to escape? Type in Y to check or update variable. Or B to restore backup.