Python 4 Beginners: how to generate a list of random values

I recently just learned how to do this without using loops: [sourcecode lang=”python”] import random x = [0 for _ in range(10)] #underscore used when you do not need the value from the list. So here 0 replaces the value from range(10) #expected out put [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] […]

Enjoy this blog? Please spread the word :)

error: Content is protected !!