Skip to content

Commit 0b26422

Browse files
authored
Removed unnecessary call to reversed in for loop
1 parent a0f5c8e commit 0b26422

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Lib/random.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ def shuffle(self, x):
355355
"""Shuffle list x in place, and return None."""
356356

357357
randbelow = self._randbelow
358-
for i in reversed(range(1, len(x))):
358+
# Iterate over the list x in reverse order
359+
for i in range(len(x)-1,0,-1):
359360
# pick an element in x[:i+1] with which to exchange x[i]
360361
j = randbelow(i + 1)
361362
x[i], x[j] = x[j], x[i]

0 commit comments

Comments
 (0)