Skip to content
Aabha AI Academy
Skip to reading

Python

03 Collections

Compare these references after your own attempt. You can read them at any time; they do not record a live model or vendor run.

# Reference answer. Attempt the exercise first.
topics = ["python", "data", "python", "charts", "data"]
counts = {}
for topic in topics:
    counts[topic] = counts.get(topic, 0) + 1
original = [20, 30]
edited = original.copy()
edited.append(40)
unique = sorted(set(topics))
assert counts == {"python": 2, "data": 2, "charts": 1}
assert original == [20, 30] and edited == [20, 30, 40]
assert unique == ["charts", "data", "python"]
print("Module 3 checks passed")

Download this source file