Hey guys, in this blog we will see a Python Program to Randomly Select an Element From the List.
Example 1: Using random module
import random my_list = ['machine', 'learning', 'projects', 1, 2, 3] print(random.choice(my_list))
Output
projects
- random.choice() is used to choose an element at random from the provided list.
Example 2: Using the secrets module
import secrets my_list = ['machine', 'learning', 'projects', 1, 2, 3] print(secrets.choice(my_list))
Output
2
- secrets.choice() is used to choose an element at random from the provided list.
Check out our other python programming examples…


![[Latest] Python for Loops with Examples – Easiest Tutorial – 2025](https://machinelearningprojects.net/wp-content/uploads/2023/05/python-for-loops-1-1024x536.webp)


