# Use global when a function must change a variable defined outside it
game_over = False

def duel():
    global game_over
    print("You raise your wand...")
    move = input("Cast (s)tun or (r)un? ")
    if move == "r":
        print("You escape!")
        game_over = True
    else:
        print("Stupefy! The duel continues.")

while not game_over:
    print("\n--- Hogwarts adventure ---")
    action = input("(d)uel, (i)nventory, (q)uit: ")
    if action == "d":
        duel()
    elif action == "q":
        game_over = True
    else:
        print("Your bag: wand, chocolate frogs")
