You can download this code by clicking the button below.
This code is now available for download.
This function uses the Fisher-Yates algorithm to shuffle the elements of a list randomly.
Technology Stack : random
Code Type : Function
Code Difficulty : Intermediate
import random
def shuffle_list(items):
"""
Shuffle a list of items using the Fisher-Yates algorithm.
"""
for i in range(len(items) - 1, 0, -1):
j = random.randint(0, i)
items[i], items[j] = items[j], items[i]
return items