[Tutor] reassign

Rikard Bosnjakovic rikard.bosnjakovic at gmail.com
Mon Apr 9 13:48:42 CEST 2007


On 4/8/07, linda.s <samrobertsmith at gmail.com> wrote:

> how i can randomly reassign the values to different location in the list?

>>> import random
>>> mylist = [1,2,3,4,5,6,7,8,9]
>>> mylist
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> random.shuffle(mylist)
>>> mylist
[3, 6, 9, 4, 7, 1, 2, 8, 5]


-- 
- Rikard - http://bos.hack.org/cv/


More information about the Tutor mailing list