Tim Chase wrote: > The closest hack I could come up with was > > import random > s = "abcdefg" > a = [] > a.extend(s) > random.shuffle(a) > s = "".join(a) > > This lacks the beauty of most python code, and clearly feels like > there's somethign I'm missing. Is there some method or function > I've overlooked that would convert a string to an array with less > song-and-dance? Thanks, > > -tim >
Would >>> import random >>> s = "abcdefg" >>> data = list(s) >>> random.shuffle(data) >>> "".join(data) 'bfegacd' >>> fit you better? -- http://mail.python.org/mailman/listinfo/python-list