You can download this code by clicking the button below.
This code is now available for download.
This function is used to shuffle the input list randomly.
Technology Stack : os, sys, datetime, random
Code Type : Function
Code Difficulty : Intermediate
import os
import sys
import datetime
import random
def shuffle_list(input_list):
if not input_list:
return []
random.seed(datetime.datetime.now())
shuffled_list = input_list[:]
n = len(shuffled_list)
for i in range(n):
j = random.randint(i, n - 1)
shuffled_list[i], shuffled_list[j] = shuffled_list[j], shuffled_list[i]
return shuffled_list