Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Daffa Alif Pratama
2,316 Points+= and list.append() difference
What's the difference between my_list += [6]
and my_list.append(6)
?
1 Answer

Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsHi Daffa
There is a difference, append just adds something to the original list where as += combines the two as its an assignment operator. list.append() is almost alot more efficient in terms of performance. Using the += operator is the same as saying list.extend().
hope this helps.
Seth Kroger
56,409 PointsSeth Kroger
56,409 PointsAlso to add to that, the difference between append() and extend() is that if you add a list append() will add the whole list as a single item (a list inside a list) while extend will add each element to the target list.
Daffa Alif Pratama
2,316 PointsDaffa Alif Pratama
2,316 PointsThanks for the help!