mix up a string

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Sun Jun 5 23:02:58 CEST 2005

rbt wrote:
> What's the best way to take a string such as 'dog' and mix it up? You 
> know, like the word jumble in the papers? ODG. I thought something like 
> mix = random.shuffle('dog') would do it, but it won't. Any tips?

py> def shuffled(s):
...     l = list(s)
...     random.shuffle(l)
...     return ''.join(l)


More information about the Python-list mailing list