470,636 Members | 1,512 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

Re: arange randomly words in a list

I have a list that looks like:
name = name1 name2 name3 name4

and I would like to be able to arrange randomly this list, like:

name = name 2 name 1 name3 name4
name = name4 name2 name1 name3

I have tried with random.shuffle, but still no good result

May I get an example?
I'm not sure what you mean by "still no good result" as using
random.shuffle works quite nicely:
>>name = "name1 name2 name3 name4".split()
['name1', 'name2', 'name3', 'name4']
>>import random
['name1', 'name3', 'name4', 'name2']
>>print ' '.join(name)
name1 name3 name4 name2

which is exactly what you describe...


Oct 25 '08 #1
0 903

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Raghuram | last post: by
reply views Thread by Shi Mu | last post: by
7 posts views Thread by Jim Carlock | last post: by
2 posts views Thread by engwar1 | last post: by
9 posts views Thread by Alan Isaac | last post: by
9 posts views Thread by Generic Usenet Account | last post: by
reply views Thread by =?ISO-8859-1?Q?BJ=F6rn_Lindqvist?= | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.