Choose random element from a list

    0

    0

    Ankit Arsh

    import random
    
    #1.A single element
    random.choice(list)
    #2.Multiple elements with replacement
    random.choices(list, k = 4)
    #3.Multiple elements without replacement
    random.sample(list, 4)
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.