Code Snippet: Shuffle Strings

From Coder Merlin™

Shuffle an Array of Strings

Swift

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

Python

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