TypeError: ‘range’ object does not support item assignment

In Python 3, range returns a lazy sequence object – it does not return a list. There is no way to rearrange elements in a range object, so it cannot be shuffled.

Convert it to a list before shuffling.

allocations = list(range(len(people)))

Leave a Comment

tech