You can download this code by clicking the button below.
This code is now available for download.
This function uses the Questionary library to create a simple multiple-choice question where the user can select an option as an answer.
Technology Stack : Questionary
Code Type : Interactive code generation
Code Difficulty : Intermediate
import random
from questionary import Question, Choice, Separator, prompt
def random_choice_question():
def xxx(question_text, choices_list):
question = Question(question_text, choices=choices_list).ask()
return question
choices_list = [
Choice("A", "Apple"),
Choice("B", "Banana"),
Choice("C", "Cherry"),
Choice("D", "Date")
]
result = xxx("What's your favorite fruit?", choices_list)
return result