Lists
Creating lists, accessing elements, adding/removing, sorting, length, and iterating with a loop.
Simple enough for a 5-year-old to understand
Create and access a list
A list holds multiple values in order. It's written with square brackets; elements are accessed with an index starting at 0.
colors = ["red", "purple", "green"]print(colors[0])print(colors[-1])Adding and length
basket = ["apple"]basket.append("pear")print(basket)print(len(basket))🎯 Exercise & Practice
Test what you've learned — answer, write code, check instantly. (1 left)