I assume that you are talking about integers. This little script should do what you want:
import random def gen_rand(number): generated = random.randint(1, 10)
Or you can use the map function instead of the for loop. Replace
myList = [gen_rand(item) for item in myList]
with
myList = map(gen_rand,myList)
source share