Python – Difference between “.append()” and “+= []”

In my new Django project, I was trying to append a list of tuples (which contained more than 1 tuple in it) into another list of tuples.

Then I got this error: ValueError: too many values to unpack (expected 2)

I was using .append() method to perform this operation and apparently that is exactly where the problem was.

Result: You cannot append a list of tuples with more than one item into another list of tuples using .append(). You need to use “+=” operator to do this.

Hope this helps.
Good Luck,
Serdar

Serdar Osman Onur
I love coding web stuff, learning/applying new technologies and techniques to create things on the internet since 2004. AboutMe G+ twitter
Serdar Osman Onur

@serdarosmanonur

hard work, determination, dedication, patience, consistency, faith
"We forge our bodies in the fire of our will" - Enter the Dragon - 1973 - 4 days ago
Serdar Osman Onur