You can download this code by clicking the button below.
This code is now available for download.
This function takes a list as an argument and returns a new list that is a randomly shuffled version of the original list.
Technology Stack : random.sample
Code Type : Function
Code Difficulty : Intermediate
import random
def shuffle_list(items):
if not isinstance(items, list):
raise TypeError("items must be a list")
shuffled = random.sample(items, len(items))
return shuffled