Python: Select an item randomly from a list
Select Random Item from List
Write a Python program to select an item randomly from a list.
Use random.choice() to get a random element from a given list.
Example - 1 :

Example - 2 :

Example - 3 :

Sample Solution-1:
Python Code:
Sample Output:
Black
Sample Solution-2:
Python Code:
Sample Output:
4
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to randomly shuffle a list and return a new list.
- Write a Python program to randomly select multiple unique items from a list.
- Write a Python program to select an item randomly from a nested list.
- Write a Python program to select a random sublist of size n from a given list.
Go to:
Previous: Write a Python program to append a list to the second list.
Next: Write a python program to check whether two lists are circularly identical.
Python Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.