[Tutor] my first project: a multiplication trainer
tiger12506
keridee at jayco.net
Mon Mar 17 17:50:40 CET 2008
> choice() returns a random element from the list of choices, not its index.
> One could call pop() instead of del, but del is probably a little faster,
> and
> doesn't return a value that we wouldn't use anyway. pop() wouldn't give
> us a
> random element, unless passed a random argument, such as
> pop(choice(range(len(choices)))), but that would be very cumbersome.
I like the shuffle idea.
n = [1,2,5,1,2,34,2,4,7,3,3,45,1,76,8]
proxy = random.shuffle(xrange(len(n)))
for idx in proxy:
dowith(n[idx])
More information about the Tutor
mailing list