vendredi 14 décembre 2018

Print different values with random in python 3.x

from random import randint

result = []
colors = {1: "Red", 2: "Green", 3: "Blue", 4: "White"}

while True:
    for key in colors:
        ball = randint(1,4)
        probability = (ball/10)
        result.append(probability)

    break

print(result)

This code gives me 4 values which is ok, but I'd like to have no repetitions. So if program took e.g "White", it won't include it to iteration. Any ideas?




Aucun commentaire:

Enregistrer un commentaire