Shuffling List with random.sample

  • Share this:

Code introduction


This function takes a list as input and returns a shuffled version of the list. It uses the sample function from the random module.


Technology Stack : random

Code Type : List scrambled

Code Difficulty : Intermediate


                
                    
import random

def shuffle_list(input_list):
    return random.sample(input_list, len(input_list))                
              
Tags: