Задать вопрос

Тел: +7 965 3737 888

448

Просмотров

0

Ответов

Real shuffle function

This function solve the issue of random.shuffle that is based only on randomized shuffling (that's not a real shuffling, because many times items returned aren't shuffled enough).

This function make a randomized shuffle and after this loops long the list resorting to avoid two items with a same value in a given attribute.

When shuffling is over and there are duplicates, they are leftover to the end (and you can remove them if you set 'remove_duplicates' to True)

Run it in a separated file to see it in action.

Вопрос полезен? Да0/Нет0
file_3968.py(2.7Кб)
None