There is another list in the list of the parent list, and when you multiply the list of the outgoing list, all the resulting list items have the same pointer to the internal list. You can create a multidimensional list recursively as follows:
def MultiDimensionalList(instance, *dimensions): if len(dimensions) == 1: return list( instance() for i in xrange( dimensions[0] ) ) else: return list( MultiDimensionalList(instance, *dimensions[1:]) for i in xrange(dimensions[0]) ) print MultiDimensionalList(lambda: None, 1, 1, 0)
[[]]
source share