Randomly Shuffle a List Function

  • Share this:

Code introduction


Implement a function that takes a list as input and returns a randomly shuffled list.


Technology Stack : os, sys, time, datetime, random, json

Code Type : List scrambled

Code Difficulty : Intermediate


                
                    
import os
import sys
import time
import datetime
import random
import json

def shuffle_list(input_list):
    """
    随机打乱列表顺序的函数
    """
    shuffled_list = random.sample(input_list, len(input_list))
    return shuffled_list

# 使用到的包和技术栈