kopia lustrzana https://github.com/micropython/micropython-lib
random: Add shuffle().
rodzic
9edb4ec580
commit
6568c0380e
|
@ -19,3 +19,9 @@ def randrange(start, stop=None):
|
||||||
|
|
||||||
def randint(start, stop):
|
def randint(start, stop):
|
||||||
return randrange(start, stop + 1)
|
return randrange(start, stop + 1)
|
||||||
|
|
||||||
|
def shuffle(seq):
|
||||||
|
l = len(seq)
|
||||||
|
for i in range(l):
|
||||||
|
j = randrange(l)
|
||||||
|
seq[i], seq[j] = seq[j], seq[i]
|
||||||
|
|
Ładowanie…
Reference in New Issue