Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
A list holds multiple values in order. That’s useful for high scores, items, or anything you need to keep in a sequence.
Use square brackets and commas:
scores = [100, 85, 92, 78]
names = ["Alex", "Sam", "Jordan"]
mixed = [10, "hello", True]
Positions start at 0, not 1:
scores[0] → 100scores[1] → 85scores[3] → 78You can also count from the end: scores[-1] is the last item, scores[-2] the second-to-last.
scores[0] = 99scores.append(88)len(scores) → 5for score in scores:
print(score)
Or with index:
for i in range(len(scores)):
print("Position", i, ":", scores[i])
Get a range of items: scores[1:3] gives the items at index 1 and 2 (not 3). So [85, 92].
append.max(scores) or a loop).Next: 3.2 Dictionaries and objects — key–value pairs for lookups.