ropering / Study

0 stars 0 forks source link

[Python] shuffle #9

Open ropering opened 2 years ago

ropering commented 2 years ago
from copy import deepcopy
from random import randint

def shuffle(lst):
    temp_lst = deepcopy(lst)
    m = len(temp_lst)
    while (m):
        m -= 1
        i = randint(0, m)
        temp_lst[m], temp_lst[i] = temp_lst[i], temp_lst[m]
    return temp_lst

foo = [1, 2, 3]
shuffle(foo)