Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | khaylaaaa |
I want to make a system where if the user inputs a word into a textEdit, it would scramble the word and output it. Thanks!
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | khaylaaaa |
I want to make a system where if the user inputs a word into a textEdit, it would scramble the word and output it. Thanks!
Reply From: | jgodfrey |
Here’s a function that takes a string as input and returns a shuffled version of it.
func shuffle_string(s):
randomize()
var a = []
for c in s: a.append(c)
a.shuffle()
return "".join(a)
Call it like:
new_string = shuffle_string("shuffleme"))
print(new_string)
Prints emfehulfs
(for example)