We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 36b705f commit 81e682fCopy full SHA for 81e682f
Doc/library/random.rst
@@ -667,10 +667,11 @@ or the :pypi:`more-itertools` project:
667
seq = tuple(iterable)
668
if len(seq) < 2:
669
raise ValueError('derangments require at least two values')
670
+ perm = list(seq)
671
while True:
- perm = random_permutation(seq)
672
+ random.shuffle(perm)
673
if all(p != q for p, q in zip(seq, perm)):
- return perm
674
+ return tuple(perm)
675
676
The default :func:`.random` returns multiples of 2⁻⁵³ in the range
677
*0.0 ≤ x < 1.0*. All such numbers are evenly spaced and are exactly
0 commit comments