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)]
More Related Contents:
- How to count the frequency of the elements in an unordered list?
- Pandas groupby.size vs series.value_counts vs collections.Counter with multiple series
- Surprising results with Python timeit: Counter() vs defaultdict() vs dict()
- Why is Collections.counter so slow?
- How to count the number of words in a sentence, ignoring numbers, punctuation and whitespace?
- Creating an Ordered Counter
- Python collections.Counter: most_common complexity
- How to sort Counter by value? – python
- Python: Removing Rows on Count condition
- How to get count dict of items but maintain the order in which they appear?
- Adding counters deletes keys
- Python: is “except KeyError” faster than “if key in dict”?
- How to count top 10 most common values in a dict in python
- How to read a single object from a json file containing multiple objects using python? [closed]
- Python eval() not multiplying properly
- What is the difference between ‘/’ and ‘//’ when used for division?
- Python string interning
- MaxRetryError: HTTPConnectionPool: Max retries exceeded (Caused by ProtocolError(‘Connection aborted.’, error(111, ‘Connection refused’)))
- zip variable empty after first use
- Tkinter lambda function
- Print to standard printer from Python?
- Pandas “Can only compare identically-labeled DataFrame objects” error
- Why do circular imports seemingly work further up in the call stack but then raise an ImportError further down?
- Select 50 items from list at random
- How to translate “bytes” objects into literal strings in pandas Dataframe, Python3.x?
- Python : Trying to POST form using requests
- How to apply NLTK word_tokenize library on a Pandas dataframe for Twitter data?
- parsing xml containing default namespace to get an element value using lxml
- heatmap-like plot, but for categorical variables in seaborn
- Pandas: Selecting rows based on value counts of a particular column