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 7ded35d commit 36b705fCopy full SHA for 36b705f
Doc/library/random.rst
@@ -665,6 +665,8 @@ or the :pypi:`more-itertools` project:
665
def random_derangement(iterable):
666
"Choose a permutation where no element is in its original position."
667
seq = tuple(iterable)
668
+ if len(seq) < 2:
669
+ raise ValueError('derangments require at least two values')
670
while True:
671
perm = random_permutation(seq)
672
if all(p != q for p, q in zip(seq, perm)):
0 commit comments