from os import system money = 1000 popularity = 1 moneypersec = 0 stress = 0 commandlist…
- User
from os import system
money = 1000 popularity = 1 money_per_sec = 0 stress = 0
command_list = ["learn", "develop", "shop"]
learn_options = { "programming": 0, "design": 0, "marketing": 0, "ceo": 0 }
learn_points = 1
def print_commands(): print("COMMANDS:\n") for i in command_list: print(f"{command_list.index(i) + 1}. {i.capitalize()}")
def cls(): system("cls")
cls() print_commands() command = input(">>")
if command.lower() in command_list and command.lower() == "learn": print("LEARN:\n") for i in learn_options: print(f"{i.capitalize()}: {learn_options.get(i)}") to_upgrade = input("Upgrade (q to quit)>>") if to_upgrade.lower() in learn_options and to_upgrade.lower() == "programming": spend = input(f"Spend 1 learn point? y\n (You have {learn_points})>>") if spend.lower() == "y": pass else: pass else: cls() print_commands()
make this code when user types q then it goes to command = input(">>") - Assistant
- User
COMMANDS:
- Learn
- Develop
- Shop
learn LEARN:
Programming: 0 Design: 0
Marketing: 0
Ceo: 0 Upgrade (q to quit)>> programming Traceback (most recent call last): File "c:\Users\RobotComp.ru\Desktop\python\games\dev-ssimulator\main.py", line 69, in learn() File "c:\Users\RobotComp.ru\Desktop\python\games\dev-ssimulator\main.py", line 48, in learn spend = input(f"Spend 1 learn point on {to_upgrade.capitalize()}? y\n (You have {learn_points})>> ").strip().lower() ^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'learn_points' where it is not associated with a value fix - Assistant