In this recipe, we will use the random module to randomly select cities from a fixed list of cities. We first create a global variable called CITIES to store these values. We can then use a specific function in the random module that is for the specific purpose of selecting random items from a list of values.
The recipe will then loop 10 times and make a random selection from the list of cities and output details of the selected city. This recipe will be particularly useful to you whenever you have a project that needs to select a certain option randomly from a fixed list of values. You might, for example, create a dice-rolling MicroPython project that should choose from the values one to six on each roll.