Home >>Python Random Module >Python Random choice() Method

Python Random choice() Method

Python Random choice() Method

Python Random choice() Method is an inbuilt method in python which is used to returns a randomly selected item from the specified list, a tuple, a string or any other kind of list.

Syntax:
random.choice(sequence)

Parameter Values

Parameter Description
sequence It is required and is a list, a tuple, a range of numbers etc.
Here is an example of Python Random choice() Method:

import random
myedu = ["Java", "Python", "mySql"]
print(random.choice(myedu))

Output:
Java
Example 2:

import random
z = "PHPTPOINT"
print(random.choice(z))

Output:
P

No Sidebar ads