Generate a random list of numbers
Seymore4Head
Seymore4Head at Hotmail.invalid
Thu Nov 19 23:05:12 EST 2015
Why does a work and b doesn't? What I was trying to accomplish with b
is to get a random list (of random length) that could have digits
repeat.
I got idea for both methods from the Internet. I do see that one uses
brackets and the other doesn't, but I don't know the difference.
import random
for i in range (5):
a = random.sample(range(10), random.randrange(3,6))
print a
for i in range (5):
b = [random.randrange (10), random.randrange(4,8)]
print b
More information about the Python-list
mailing list