KnowledgeBoat Logo

Computer Science

What is the difference between appending a list and extending a list?

Python List Manipulation

35 Likes

Answer

Appending a listExtending a list
For appending to a list, append() function is used.For extending a list, extend() function is used.
The append() function can add a single element to the end of a list.The extend() function can add multiple elements from a list supplied to it as argument.
After append(), the length of the list will increase by 1 element only.After extend() the length of the list will increase by the length of the list given as argument to extend()

Answered By

20 Likes


Related Questions