You can download this code by clicking the button below.
This code is now available for download.
This Python function uses the PyInquirer library to create a simple interactive survey that collects the user's username, programming language preference, and willingness to subscribe to a newsletter.
Technology Stack : PyInquirer
Code Type : Python Function
Code Difficulty : Intermediate
import random
from pyinquirer import prompt, List
def custom_pyinquirer_function():
questions = [
{
"type": "input",
"name": "username",
"message": "Enter your username:"
},
{
"type": "list",
"name": "language",
"message": "Choose a programming language:",
"choices": ["Python", "JavaScript", "Java", "C#"]
},
{
"type": "confirm",
"name": "subscribe",
"message": "Do you want to subscribe to our newsletter?"
}
]
answers = prompt(questions)
return answers