You can download this code by clicking the button below.
This code is now available for download.
This function uses the select and Choice classes from the Questionary library to randomly select a fruit.
Technology Stack : Questionary
Code Type : Function
Code Difficulty : Intermediate
def random_choice_questionary():
import random
from questionary import select, Choice
choices = [
Choice("apple", "Apple"),
Choice("banana", "Banana"),
Choice("cherry", "Cherry"),
Choice("date", "Date"),
Choice("elderberry", "Elderberry")
]
selected_choice = select(choices).ask()
return selected_choice.value
# JSON representation of the function