1
You visited us
1
times! Enjoying our articles?
Unlock Full Access!
Byju's Answer
Standard XI
Statistics
Tally Mark
How to shuffl...
Question
How to shuffle a list in python?
Open in App
Solution
The easiest way to shuffle a list is using the shuffle() in-built function of the random library. If we pass a list through the shuffle() in-built function then it will return the shuffled list.
Example:
import random #importing the random library
myList = [1, 2,3, 4]
random.shuffle(myList) # shuffling the list
print(myList)
Output:
[3, 2, 1, 4]
Suggest Corrections
0
Join BYJU'S Learning Program
Grade/Exam
1st Grade
2nd Grade
3rd Grade
4th Grade
5th Grade
6th grade
7th grade
8th Grade
9th Grade
10th Grade
11th Grade
12th Grade
Submit
Related Videos
Frequency Distribution Table
STATISTICS
Watch in App
Explore more
Tally Mark
Standard XI Statistics
Join BYJU'S Learning Program
Grade/Exam
1st Grade
2nd Grade
3rd Grade
4th Grade
5th Grade
6th grade
7th grade
8th Grade
9th Grade
10th Grade
11th Grade
12th Grade
Submit
AI Tutor
Textbooks
Question Papers
Install app