Write a program that defines a function (shuffle) to scramble a list into a random order, like shuffling a deck of cards.
Are you looking to shuffle a list in Python? Whether you’re working on a card game or just need to randomize a list, shuffling a list is a common task in programming.
| Learn Python Online Course with “ Computer Courses — All in One “
In this blog post, we’ll walk you through how to write a program that defines a function to shuffle a list into a random order, like shuffling a deck of cards.

Table of Contents:
- Problem Statement
- What is shuffling a list?
- How to shuffle a list in Python
| Practice Python Programming MCQ with “Python MCQ Programs Interview “ Android App.
Problem Statement: Python Program to Shuffle Deck of Cards
Write a program that defines a function (shuffle) to scramble a list into a random order, like shuffling a deck of cards.
What is shuffling a list?
Shuffling a list means to randomize the order of the elements in the list. This is often used in card games, where the order of the cards in the deck needs to be randomized before dealing.
How to shuffle a list in Python
Python has a built-in function called shuffle() that can be used to shuffle a list. Here’s an example of how to use it:
import random
my_list = [1, 2, 3, 4, 5]
random.shuffle(my_list)
print(my_list)
This will output a shuffled version of the list, like [3][1][5][4][2].