xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to shuffle elements of a list in Python
Python Online Editor
Execute Code
More Python Sample Codes
# import random module to shuffle a list element import random #First example with list of integer int_list = [1, 2, 3, 4, 5, 6, 7, 8, 9] # list of integer print("Original list elements: ", int_list) random.shuffle(int_list) #random.shuffle() function applied print("Shuffled list elements: ", int_list, "\n") #Second example with list of string str_list = ["apple", "banana", "mango", "orange"] # list of string print("Original list elements: ", str_list) random.shuffle(str_list) #random.shuffle() function applied print("Shuffled list elements: ", str_list)