In-Place List Shuffling Function

  • Share this:

Code introduction


Defined a function that takes a list as an argument and shuffles its elements in place.


Technology Stack : Random

Code Type : Function

Code Difficulty : Intermediate


                
                    
import random

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

    return items                
              
Tags: