def purchase_flag(balance): while True: print("Welcome to the CTF Store Challenge!") print("Your balance: $" + str(balance)) print("Options:") print("1. Curtains of Houses - $4") print("2. Dining Table - $30") print("3. Flag of the Office - $49") print("4. Another item (Search for items)") print("5. Exit") choice = input("Enter your choice: ") if choice == "1": if balance >= 4: balance -= 4 print("You purchased the Curtains of Houses. Your balance is now $" + str(balance)) else: print("You don't have enough money to buy the Curtains of Houses.") elif choice == "2": if balance >= 30: balance -= 30 print("You purchased the Dining Table. Your balance is now $" + str(balance)) else: print("You don't have enough money to buy the Dining Table.") elif choice == "3": if balance >= 49: balance -= 49 print("Congratulations! You purchased the Flag of the Office, which is the challenge flag.") print("Your balance is now $" + str(balance)) return True else: print("You don't have enough money to buy the Flag of the Office.") elif choice == "4": while True: print("Searching for item...") item = input("Enter the item you want to search for: ") try: result = eval(item) balance = result print("Sorry, the item you are looking for is not available.") except Exception: print("Invalid input. Please enter a valid expression.") print("Options:") print("1. Search again") print("2. Back to list") search_choice = input("Enter your choice: ") if search_choice == "1": continue elif search_choice == "2": break else: print("Invalid choice. Returning to the list of options.") elif choice == "5": print("Exiting the CTF Store Challenge. Goodbye!") return False else: print("Invalid choice. Please enter a number between 1 and 5.") balance = 10 purchase_flag(balance)