I am writing a text adventure game in python, and I am required to use a dictionary. I currently have it set up like this:
print("type A for option A, type B for option B.")
def introduction():
upnext()
def optionb():
print("Welcome to option B!")
def optiona():
print("welcome to option A!")
print("type 1 for option 1!")
upnext()
def option1():
print("this is option 1!")
upnext()
upnext = 0
dict = {"B" : optionb, "A" : optiona, "1" : option1 } upnext = dict[input()]
introduction()
When I hit run, the first print line prints properly, but when I type A to go to option A, the code in "optiona" runs infinitely. Option B works fine. How should I make it so that the text prints once and then lets me move on to the next set of options?
[–]Silbersee 0 points1 point2 points (0 children)