First thing you should know is, randint(start, end)
function randomly generates number starting from the start
to end
. So in your case, it generates a number more than what indexes you have in your lists. You can do,
people = randint(0, len(persons)-1)
More Related Contents:
- syntax error in the code in the line break list due to the input, how do you adjust this? [closed]
- Splitting up a numbers in Python
- How to use variables from a function in a different function
- How do you append to a file?
- Dynamically set local variable [duplicate]
- When to use and when not to use Python 3.5 `await` ?
- Slice 2d array into smaller 2d arrays
- Python Requests library redirect new url
- How to write DataFrame to postgres table
- Python list confusion [duplicate]
- How to compare dates in Django templates
- import text to pandas with multiple delimiters
- Import could not be resolved/could not be resolved from source Pylance in VS Code using Python 3.9.2 on Windows 10
- How to convert nested list of lists into a list of tuples in python 3.3?
- How to write your own LaTeX preamble in Matplotlib?
- How to run a http server which serves a specific path?
- pandas comparison raises TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
- What’s the easiest way to add commas to an integer? [duplicate]
- Running Jupyter with multiple Python and IPython paths
- How do I filter a pandas DataFrame based on value counts?
- Print without b’ prefix for bytes in Python 3
- How do I install Python packages in Google’s Colab?
- Anaconda: Permanently include external packages (like in PYTHONPATH)
- PIL: DLL load failed: specified procedure could not be found
- How to convert epoch time with nanoseconds to human-readable?
- How do I install Python libraries in wheel format?
- Remove NaN values from pandas dataframe and reshape table [duplicate]
- sampling random floats on a range in numpy
- Using %matplotlib notebook after %matplotlib inline in Jupyter Notebook doesn’t work
- How can I specify a database for Django Tests to use instead of having it build it every time?