Randomizing Word List

  • Share this:

Code introduction


This function takes a list of words as an argument and returns a new list with the words in a random order.


Technology Stack : random

Code Type : Function

Code Difficulty : Intermediate


                
                    
import random

def shuffle_words(words):
    """
    随机打乱一个单词列表。

    参数:
    words (list): 要打乱的单词列表。

    返回:
    list: 打乱后的单词列表。
    """
    return random.sample(words, len(words))

# JSON 格式输出                
              
Tags: