Sep-05-2018, 07:59 PM
In previous posts there was no
My suggestion was based on this piece of code:
random.shuffle
to be seen.My suggestion was based on this piece of code:
numbers = [0,1,2,3,4,5,6,7,8,9] ... for num in numbers: print(num, end='\t')Which can be expressed:
for num in range(10): print(num, end='\t')Regarding random.shuffle: best way is to start with built-in help:
>>> import random >>> help(random.shuffle) Help on method shuffle in module random: shuffle(x, random=None) method of random.Random instance Shuffle list x in place, and return None. Optional argument random is a 0-argument function returning a random float in [0.0, 1.0); if it is the default None, the standard random.random will be used. (END)Your code will not work, it doesn't matter whether you use
for num in numbers
or for num in range(10)
, argument must be a list. >>> import random >>> r = list(range(10)) >>> random.shuffle(r) >>> r [1, 8, 2, 5, 4, 9, 0, 6, 7, 3] >>> random.shuffle(r) >>> r [0, 6, 5, 1, 4, 7, 9, 2, 3, 8]
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.