You can download this code by clicking the button below.
This code is now available for download.
This function uses the prompt method from the PyInquirer library to select a user from a given list.
Technology Stack : PyInquirer
Code Type : User selection function
Code Difficulty : Intermediate
def select_random_user(input_list):
import random
from pyinquirer import prompt
questions = [
{
"type": "list",
"name": "user",
"message": "Select a user from the list:",
"choices": input_list
}
]
answer = prompt(questions)
return answer["user"]