Shuffle List Python || Python

 

In this we are going to see a program on how to Shuffle List Python using random module in Python Programming Language.


import random

def shuffle(lst):
    for i in range(len(lst)):
        random_index = random.randrange(0, len(lst))
        lst[i], lst[random_index] = lst[random_index], lst[i]
    return lst

print(shuffle([1, 2, 3, 4, 5, 6, 7, 8, 9]))

# Coded By DHIRAJ SHELKE

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post