How can I make a word scrambler?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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!

:bust_in_silhouette: 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)