Python Number Shuffle() Method



The shuffle() method in Python number randomizes the items within a list in place. Python Random shuffle() Method in Python programming takes a sequence i.e. list, string, or tuple, and further reorganizes the items present there in order. This method of Python Random Module is supposed to change the original tuple/list/string, and it does not return the new tuple/list/string.


Here is the syntax for shuffle() method:

shuffle (lst )

Note - One cannot access this function directly, so it is required to import the random module in Python, and then we are supposed to call this function making use of the random static object.


  • lst - This can be a list or tuple.

Return Value

This method in Python random number functions does not return any value.


The example below shows the usage of shuffle() method.

import random

list = [20, 16, 10, 5];
print "Reshuffled list : ",  list

print "Reshuffled list : ",  list

When we run the above program, it produces the following result:

Reshuffled list :  [16, 5, 10, 20]
Reshuffled list :  [16, 5, 20, 10]

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.