![]() |
how to put string in random order - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: how to put string in random order (/thread-12407.html) |
how to put string in random order - witch - Aug-23-2018 so I have a randomly generated string consisting of numbers and letters , it looks like 184uwkdf, how do i make it random like 1u4df8kw ? Is there a function for it ? RE: how to put string in random order - snippsat - Aug-23-2018 shuffle it with random module. >>> import random >>> >>> s = list('184uwkdf') >>> random.shuffle(s) >>> ''.join(s) 'f8u4k1wd' >>> random.shuffle(s) >>> ''.join(s) 'fw8du1k4' RE: how to put string in random order - witch - Aug-23-2018 (Aug-23-2018, 11:34 AM)snippsat Wrote: shuffle it with random module. Thanks ! You really helped :) |