H2K Infosys Forum

AI Assistant
What is the differe...
 
Notifications
Clear all

What is the difference between append() and extend() in lists?

 
Member Moderator
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

In Python, the difference between append() and extend() is essential to understand, especially for beginners taking a python programming training course:

  • append() adds an object as a single element to the end of the list.

  • extend() adds each element of an iterable individually into the list.

Example:

 
a = [1, 2]
a.append([3, 4]) # ➝ [1, 2, [3, 4]]

a.extend([3, 4]) # ➝ [1, 2, 3, 4]

This is a common interview question and a core concept taught in every good python programming training course because it helps learners understand list behavior and data manipulation more effectively.


Quote
Topic starter Posted : 13/11/2025 11:30 am
Share: