You’ll have to pre-fill it with something (e.g. 0 or None) before you can index it:
myList = [None] * 100 # Create list of 100 'None's
myList[12] = 'a' # etc.
Alternatively, use a dict instead of a list, as Alex Martelli suggested.
You’ll have to pre-fill it with something (e.g. 0 or None) before you can index it:
myList = [None] * 100 # Create list of 100 'None's
myList[12] = 'a' # etc.
Alternatively, use a dict instead of a list, as Alex Martelli suggested.