Skip to content

How to make a multiple-choice question in Python | Example code

Using while true with if statement you can make a multiple-choice question in Python. stop the loop if the user enters “Q”.

Example make a multiple-choice question in Python

Simple example code making a very simple multiple-choice story in Python, repeat if neither of the options is selected.

while True:
    d1a = input("Do you want to: \n A) House. B) Stable. [A/B]? : ")
    if d1a == "A":
        print("You approach the cottage.")
    elif d1a == "B":
        print("You approach the stables.")
    elif d1a == "Q":
        print("Done!")
        break

Output:

How to make a multiple-choice question in Python

Do comment if you have any doubts or suggestions on this Python program code.

Note: IDE: PyCharm 2021.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

2 thoughts on “How to make a multiple-choice question in Python | Example code”

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.