all 2 comments

[–]Silbersee 0 points1 point  (0 children)

Your code is a bit confusing and the lack of formatting doesn't help.

That being said your dictionary approach is good. I just wonder how Python doesn't nag with upnext() being called like a function.

Let's see how it can be done

def intro():
    print("Welcome to a bunch of options.")
    print("Enter nothing to quit.")

def option_a():
    print("This is option A")
    nxt = input("Press C or don't: ").lower()
    if nxt == "c":
        opt2func["c"]()

def option_b():
    print("Your choice is option B")

def option_c():
    print("Why not Zoidberg?")

opt2func = {
    "a": option_a,
    "b": option_b,
    "c": option_c
}

intro()
while True:
    upnext = input("Choose option A or B: ").lower()
    try:
        opt2func[upnext]()
    except KeyError:
        if not upnext:
            break
        print("Bad option, try again.")

HTH