Randomly Shuffle List Elements Function

  • Share this:

Code introduction


This function takes a list as an argument and shuffles the order of its elements using the shuffle method from the random module.


Technology Stack : random

Code Type : Function

Code Difficulty : Intermediate


                
                    
import random

def shuffle_list(items):
    """
    随机打乱列表中元素顺序的函数。
    """
    random.shuffle(items)
    return items                
              
Tags: