# Python Program to Shuffle Deck of Cards

PythonServer Side ProgrammingProgramming

When it is required to shuffle a deck of cards using Python, the 'itertools' and the 'random' packages need to be used. Random library has a method named 'shuffle' that can be used to mix up and show the data.

Below is a demonstration for the same −

## Example

Live Demo

import itertools, random
print("The cards are being shuffled")
random.shuffle(my_deck)
print("Cards are drawn at random")
print("They are : ")
for i in range(5):
print(my_deck[i][0], "of", my_deck[i][1])

## Output

The cards are being shuffled
Cards are drawn at random
They are :
1 of Diamond
5 of Diamond
4 of Club
4 of Heart