You can download this code by clicking the button below.
This code is now available for download.
Defined a function that takes a list as an argument and then uses the shuffle function from the random library to shuffle the elements of the list.
Technology Stack : Defined a function that takes a list as an argument and then uses the shuffle function from the random library to shuffle the elements of the list.
Code Type : Function
Code Difficulty : Intermediate
import random
def shuffle_list(input_list):
"""
将输入列表中的元素随机打乱。
参数:
input_list (list): 要打乱的列表。
返回:
list: 打乱后的列表。
"""
shuffled_list = input_list.copy()
random.shuffle(shuffled_list)
return shuffled_list
# JSON描述