Randomly Shuffle List Function

  • Share this:

Code introduction


This function takes a list of items and randomly shuffles its order, returning a new list with the shuffled items.


Technology Stack : random

Code Type : Function

Code Difficulty : Intermediate


                
                    
import random

def shuffle_list(items):
    """
    Randomly shuffle a list of items.
    """
    random.shuffle(items)
    return items                
              
Tags: