(TIL) Python: Difference between append and ‘+=’

less than 1 minute read

In many applications += and append are interchangeable, but for Python lists they are not.

If you are appending a list of lists to another list of lists, append will only append the first list; you need to use += in order to join all of the lists at once.

Via Kaggle.com.

Comments