Ask coding questions

← Back to all posts
I want to add a shop to my Text Adventure Game
AdvaitoWan (1)

I am trying to make a shop for my game but I don't know how to. All the ones i can find have errors. Pls help. Thanks!

Comments
hotnewtop
robowolf (548)

Just define a function with a global variable of currency. The put some items or lives integrated in the game. Here's a template.

def shop():
    global money
    global lives
    while True:
     thing = input('What would you like to buy? A. Lives B. Exit')
     if thing == 'A':
         if money >= {price}:
               lives+=1
         else:
             print("You don't have enough money")
     else:
       print('Bye')
       mainmenu()
        
   
LukeWright (281)

link the code and tell what the error is.

figglediggle (140)

Did you link the wrong repl? This is a discord bot