Shuffle Characters in String using Python

random.sample function

import random

text = 'Hello'
result = ''.join(random.sample(text, len(text)))

print(result)

Leave a Comment

Cancel reply

Your email address will not be published.