[Python] Python Random.Choice EXCEPT One Option

Discussão em 'Python' iniciado por Stack, Fevereiro 2, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use random.choice() to select an item from a dictionary, however, I would like one of the items to be ignored entirely. For example:

    mutationMarkers = {0: "original", 1: "point_mutation", 2: "frameshift_insertion",
    3: "frameshift_deletion", 4: "copy_number_addition",
    5: "copy_number_subtraction"}

    mutator = choice(list(markers)) # output is 0, 1, 2, 3, 4, 5


    Is it possible to use random.choice and ignore {0: "original"}?

    Continue reading...

Compartilhe esta Página