Building a list inside a list in python
You could append empty lists until you have enough to access the index you have data for: However, you may want to use a dictionary instead, letting you implement a sparse object instead. A collections.defaultdict() object is especially useful here: data now has keys 2 and 5, each a list with one element. No entries … Read more