Shuffle List Elements Randomly

  • Share this:

Code introduction


Randomly shuffles the elements of a list and returns a new list with the same elements in a different order.


Technology Stack : random.sample

Code Type : List scrambled

Code Difficulty : Intermediate


                
                    
import random
import json

def shuffle_list(input_list):
    return random.sample(input_list, k=len(input_list))