Sorted list - how to change it
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Thu Nov 9 05:05:14 EST 2006
In <1163065969.593970.165600 at b28g2000cwb.googlegroups.com>, Lad wrote:
> I have a sorted list for example [1,2,3,4,5] and I would like to change
> it in a random way
> e.g [2,5,3,1,4] or [3,4,1,5,2] or in any other way except being
> ordered.
lst = [1, 2, 3, 4, 5]
tmp = list(lst)
while lst == tmp:
random.shuffle(lst)
If you *really* want to be sure it's not sorted after shuffling. :-)
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list