Lists - Python Arrays
Store and manipulate collections
Beginner⏱️ 15 minutes
Lesson Content
Python Lists
Lists store multiple items in order.
Creating Lists:
fruits = ["apple", "banana", "orange"]
numbers = [1, 2, 3, 4, 5]
mixed = [1, "hello", True, 3.14]
List Methods:
fruits.append("grape") # Add to end
fruits.remove("banana") # Remove by value
fruits.pop() # Remove last item
len(fruits) # Get length
fruits[0] # Access first item
Looping Lists:
for fruit in fruits:
print(fruit)
Task: Create a list of 3 languages, add "Python", remove first one, then print each.
python
Loading...
Expected Output: CSS
Next (Complete this lesson first)
Functions in Python