[Tutor] my first project: a multiplication trainer

Kent Johnson kent37 at tds.net
Sun Mar 16 18:18:14 CET 2008


tiger12506 wrote:
> n = [1,2,5,1,2,34,2,4,7,3,3,45,1,76,8]
> proxy = random.shuffle(xrange(len(n)))

shuffle() shuffles in place, it doesn't return the shuffled list.
> for idx in proxy:
>   dowith(n[idx]) 

Why not shuffle n directly?

n = ...
random.shuffle(n)
for x in n:
   dowith(x)

Kent


More information about the Tutor mailing list