jeudi 15 avril 2021

Python, Is there a way to use list comprehension to form a list of 10 random floats between 0 and 1? [duplicate]

I am a beginner to python (or coding in general!) and I am currently learning list comprehension. What I want to ask is if there exists a method to generate an array of floats between 0 and 1 using only list comprehension. The output should give the same result as :

for a in range(100):
    i = random()
    list.append(i)
print(list)

Any help would be appreciated :)




Aucun commentaire:

Enregistrer un commentaire