Random List Shuffler Function

  • Share this:

Code introduction


Defined a function that randomly shuffles the elements of the input list.


Technology Stack : random

Code Type : Function

Code Difficulty : Intermediate


                
                    
import random

def shuffle_list(input_list):
    """
    Randomly shuffles the elements of the input list.

    :param input_list: list of elements to be shuffled
    :return: a shuffled list
    """
    shuffled_list = input_list.copy()
    random.shuffle(shuffled_list)
    return shuffled_list                
              
Tags: