Having trouble making a list of lists of a designated size [duplicate]

Using [[]]*5000, you are creating 5000 reference to the same list in your outer list. So, if you modify any list, it will modify all of them.

You can get different lists like this:

a = [[] for _ in xrange(5000)]

Leave a Comment