In-Place List Shuffling Function

  • Share this:

Code introduction


Defined a function that accepts a list as input and shuffles the elements of the list in-place.


Technology Stack : random

Code Type : Function

Code Difficulty : Intermediate


                
                    
import random

def shuffle_list(input_list):
    """
    Shuffle the elements of the input list in-place.
    """
    random.shuffle(input_list)

    return input_list                
              
Tags: