random.shuffle question

dsavitsk dsavitsk at e-coli.net
Mon Sep 9 12:51:11 EDT 2002


why does this not work to shuffle part of a list?

>>> l = [1,2,3,4,5,6,7,8,9]
>>> random.shuffle(l[4:8])
>>> print l
[1, 2, 3, 4, 5, 6, 7, 8, 9]

and more importantly, is there a better way to do this?

-d





More information about the Python-list mailing list