Shuffling Words in a List Function

  • Share this:

Code introduction


This function takes a list of words as input and returns a new list with the words shuffled.


Technology Stack : random.sample

Code Type : Python Function

Code Difficulty : Intermediate


                
                    
import random

def shuffle_words(words):
    # This function takes a list of words and returns a new list with the words shuffled.
    shuffled_words = random.sample(words, len(words))
    return shuffled_words

# JSON explanation