Difference between append and extend in list in python
Before going further, we need to run one example on this, we can get to know understand.
a = [1, 2] a.append([3, 6]) print("By using append method", a) a = [1, 2] a.extend([3, 6]) print("By using extend method", a)
By observing the above example, you will get know understand
Extend(): This extend will simply adding the elements to that old list
Append(): This method it append a object at end of the list