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)))
More Related Contents:
- Why does integer division yield a float instead of another integer?
- What do ellipsis […] mean in a list?
- Pinging servers in Python
- Reading file using relative path in python project
- Could not load dynamic library ‘cudart64_101.dll’ on tensorflow CPU-only installation
- Is there a ceiling equivalent of // operator in Python?
- asyncio.sleep() vs time.sleep()
- Set up Python 3 build system with Sublime Text 3
- PyQt4 to PyQt5 how?
- Python unpacking operator (*)
- Removing the TK icon on a Tkinter window
- building Python from source with zlib support
- Python 3.1.1 string to hex
- EOFError: EOF when reading a line
- Python TypeError: non-empty format string passed to object.__format__
- pandas or python equivalent of tidyr complete
- How do I run python 2 and 3 in windows 7? [duplicate]
- Self-reference or forward-reference of type annotations in Python [duplicate]
- ‘ModuleNotFoundError’ when trying to import module from imported package
- Is Python’s order of evaluation of function arguments and operands deterministic (+ where is it documented)?
- How to make a command case insensitive in discord.py
- What does the slash mean when help() is listing method signatures?
- Appending to list in Python dictionary [duplicate]
- Converting python string into bytes directly without eval()
- Python 3.4: How to import a module given the full path? [duplicate]
- How to change all the dictionary keys in a for loop with d.items()?
- Anaconda unicode error on command line startup on Windows
- bash: Python import – Command not found for pandas
- Issue with regex backreference in Python
- What difference between pickle and _pickle in python 3?