random.shuffle question

dsavitsk dsavitsk at e-coli.net
Mon Sep 9 18:51:11 CEST 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