On June 18th at 10:00 AM UTC Academy will be unavailable for 5 minutes due to planned maintenance break.
Rainbow Deals - hours only!Up to 80% off on all courses and bundles.-Close
List basics
Lists with if statements and loops
Lists in functions
22. Summary


All right, it's time to wrap things up!

  • List definitions require elements separated with commas inside square brackets:

    invited_guests = ['Mark', 'Hannah', 'Walter']
  • List elements are accessed with square brackets. Indexing starts at 0.

    # first element
    # first and second element
  • To add a new element:

    # way one
    invited_guests.append('New Guest')
    # way two
    invited_guests + ['New Guest']
  • To delete an element from a list:

    # when you know the index
    del invited_guests[2]
    # when you know the value
  • To iterate over a list:

    # when you don't need the index
    for guest in invited_guests:
    # when you need the index
    for guest in range (0, len(invited_guests)):
  • Lists can be used as function arguments. They can also be returned from functions.

Alright, it's time for a short quiz!


Click Next exercise to continue.