By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,583 Members | 1,883 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,583 IT Pros & Developers. It's quick & easy.

Re: arange randomly words in a list

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.