• About
  • Images
  • Blog
  • Talks
  • Contact
Menu

Roberto Reif

Technology and Data Trainings

Your Custom Text Here

Roberto Reif

  • About
  • Images
  • Blog
  • Talks
  • Contact

PYTHON LISTS: Append versus Extend

February 4, 2025 Roberto Reif

When working with Python lists, we can add elements to the end of the main list in two ways:

  • To add a single item (object) to the end of the list, we use the append method. This increases the list's length by 1. Note that appending another list creates a list of lists.

  • To extend the list by adding each element from an iterable (e.g., list, tuple, set), we use the extend method. This increases the list's length by the number of elements in the iterable.

What other Python-related questions do you have?

← Pie Versus Bar ChartsWhy is a Number Raised to the Power of 0 Equal to 1? →