You can download this code by clicking the button below.
This code is now available for download.
Defined a function to randomly shuffle the elements of an input list.
Technology Stack : random (random number generation)
Code Type : Function
Code Difficulty : Intermediate
import random
def shuffle_list(input_list):
"""
Randomly shuffles the elements of the input list.
Args:
input_list (list): The list to be shuffled.
Returns:
list: A new list with elements shuffled.
"""
shuffled_list = input_list.copy()
random.shuffle(shuffled_list)
return shuffled_list