Code Snippet: Shuffle Strings

From Coder Merlin

Shuffle an Array of Strings[edit]

Swift[edit]

let verbs = ["walk", "jump", "run", "swim", "dance"]
let shuffledVerbs = verbs.shuffled()
for verb in shuffledVerbs {
    print(verb)
}

Python[edit]

import random
verbs = ["walk", "jump", "run", "swim", "dance"]
random.shuffle(verbs)
print(verbs)


Designed with pride in Silicon Valley, CA, USA