Some tips about python this week

List of lists in python
Created a list of lists by using multiply symbol:

It’s weird that adding one item to first list have side-effect on second list! Seems ‘* 2’ makes two reference for one list.
How to avoid this then? The answer is using normal syntax:

A difference between python2 and python3
There are many trivial differences between python3 and python3, and I luckily found one this week:

In python3, the values() of a dictionary is not type of ‘list’ but ‘dict_values’. To be compatible to python2, we need to add

for old python2 codes.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.