mercredi 4 mars 2020

Create a list of boolean values based on cutoff

I'm trying to generate a list with a variable that I can control. So let's say I want to generate a list of length 100 with conditions:

[True if x > 0.8 else False for x in [random_number_between_0_and_1]]

So the list will have 2:8 True/False values, and so on. I tried something like this but my syntax is off:

    my_list = []
    True if x > 0.8 else False for x in random()
    my_list.append(i)

Any help is appreciated!




Aucun commentaire:

Enregistrer un commentaire