Shuffle List Function

  • Share this:

Code introduction


This function takes a list as input and returns a new list with the elements shuffled.


Technology Stack : random.sample

Code Type : List operation

Code Difficulty : Intermediate


                
                    
import random

def shuffle_list(input_list):
    """
    This function takes a list as input and returns a shuffled version of the list.
    """
    return random.sample(input_list, len(input_list))