mardi 22 juin 2021

Is there a way to round a random float list to the nearest 0.5?

import random

random_foot_size = []
for i in range(0, 10):
    r = round(random.uniform(1, 13), 1)
    half_size = [round(num * 2) / 2 for num in random_foot_size]
    random_foot_size.append(r)

print(random_foot_size)

This is what I have so far. But I can't seem to get it rounded to the nearest 0.5




Aucun commentaire:

Enregistrer un commentaire