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 with the elements shuffled randomly.
Technology Stack : random
Code Type : List operation
Code Difficulty : Intermediate
import random
def shuffle_list(arg1):
"""
Randomly shuffles the elements in a given list.
"""
if not isinstance(arg1, list):
raise TypeError("arg1 must be a list")
shuffled_list = arg1[:]
random.shuffle(shuffled_list)
return shuffled_list