1. Main welcome to the shop menu to select which type of shopping you'd like to do
2. Attack skills menu
3. Other skills menu
4. Upgrade menu
Once the player has completed the shopping they wished to do I use a Break command to back out into the previous menu.
Before I started adding submenus the process worked out well enough. Now, however, the break commands generate errors. Specifically: SyntaxError: 'break' outside loop
Here is the relevant coding, although I suspect the issue is a misunderstanding on my part and not the code itself:
- Code: Select all
# The main menu of the shop
shopping = 'yes'
print("Welcome to the Shop.")
shopping = input("1 for attacks, 2 for skills> ")
while shopping == '1':
while shopping == '2':
# The Attacks purchasing menu
num = 1
for i in ATTACKZ:
# format: "1 ) Name, Cost"
print(num, ")", str([i])[2:-2], [i], "exp\n")
num += 1
print("What would you like to buy?")
print("When you've finished shopping type '0'.")
choice = int(input("> ")) - 1 # -1 to compensate for numbering
if choice == -1:
break # this is where the error seems to come from
purchase = choice
buying(ATTACKZ[purchase], exp, purchase)
I've left out "buying()" and "ATTACKZ" because I don't believe they're related to the issue.
Oh, and of course "shop()" is referenced further on in the coding.
I believe that is everything. Questions, explanations, and suggestions are all welcome.
Thanks in advance,