bhylu.com

Advertisements

Code Challenge

Create independent attendee lists for two courses, then add a name to only one course.

Understand the idea

Write your own solution before opening the worked answer. Predict the output from the supplied values, then compare the actual result. Check both an ordinary case and the boundary described below; a passing example is more useful when you can explain why it passes.

Where to try it

Open this example with Try in playground. The code loads as editable text and does not run until you select Run. The first run downloads Python. Each run starts fresh; temporary files created by a script are not files on your PC.

Your task

Create independent attendee lists for two courses, then add a name to only one course.

Show the worked solution
Python

groups = {title: [] for title in ["SQL", "Python"]}
groups["Python"].append("Asha")
print(groups)

Check the result

Only Python contains Asha; SQL remains an empty list.

Test one more case

Prove the two list objects are not identical with an is comparison.