I’m very new to python.
I would like to have an array of exactly 10000 big integers (arbitrary precision).
I tried to do it like this:
M = []
M[0] = 1
M[1] = 1
for k in range(2,10001):
M[k] = ...
but I get:
IndexError: list assignment index out of range
What data structure should I use and how do I initialize it and reserve space for it?
The list isn’t initialized correctly.
Try
M = [0]*10000. This will give you a list of the correct size. Just replace the0with whatever default you want (or overwrite it with the right value afterwards).