Random List Shuffler

  • Share this:

Code introduction


This function takes a list as an argument and returns a new list with the items shuffled randomly.


Technology Stack : random

Code Type : Function

Code Difficulty : Intermediate


                
                    
import random

def shuffle_list(items):
    """
    Randomly shuffles a list of items.

    :param items: List of items to be shuffled.
    :return: A new list with the items randomly shuffled.
    """
    shuffled_items = items[:]
    random.shuffle(shuffled_items)
    return shuffled_items                
              
Tags: