Implement a picker wheel in Python 3 using random

A very simple implementation in Python 3 using the random module

Discovering the diverse universe of craft beers can be both an exciting and overwhelming journey. But how do you choose which beer style to try next?
Enter: the Craft-Beer Picker Wheel.

import random

def picker_wheel(choices):
    """Select a random choice from a list."""
    choice = random.choice(choices)
    return choice

beer_types = [
    "Bières IPA (India Pale Ale)",
    "Bières Stout",
    "Bières Sour Ale",
    "Bières Saison/Farmhouse Ale",
    "Bières Porte",
    "Bières Lager",
    "Bières Pilsner",
    "Bières de Blé (Wheat Beers)",
]

selected_beer = picker_wheel(beer_types)
print("The picker wheel selected:", selected_beer)

Usage and result

user@computer % python3 craft_beer_picker_wheel.py
The picker wheel selected: Bières Sour Ale

In this script:

  1. We import the random module, which provides functionality for generating random numbers and making random choices.

  2. We define a function picker_wheel that takes a list of choices and returns a random choice from that list. It uses the random.choice function to do this.

  3. We define a list of beer types.

  4. We use the picker_wheel function to select a random beer type.

  5. We print out the selected beer.