Random Element Extraction from List

  • Share this:

Code introduction


This function randomly extracts an element from the provided list.


Technology Stack : random

Code Type : Function

Code Difficulty : Intermediate


                
                    
def extract_random_element_from_list(input_list):
    """
    Extracts a random element from a given list.

    :param input_list: List from which to extract a random element.
    :return: A random element from the input list.
    """
    import random
    return random.choice(input_list)                
              
Tags: