Python Practice Problems
Use repeatable practice problems to check whether you can explain results, not just reproduce familiar code. Include empty input, missing values, and duplicate data.
Understand the idea
Find the first available workshop from a sequence of records. Preserve the difference between no match and a matching record with an index of zero. The worked generator expression supplies a default to next so an empty match set has a defined result. This is a small selection task, not an excuse to hide a large workflow in one line.
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
Use repeatable practice problems to check whether you can explain results, not just reproduce familiar code. Include empty input, missing values, and duplicate data.
Show the worked solution
workshops = [{"title": "SQL", "seats": 0}, {"title": "Python", "seats": 4}]
first = next((item for item in workshops if item["seats"] > 0), None)
print(first["title"] if first is not None else "No availability")
Check the result
The selected title is Python.
Test one more case
Test no available workshops and an available workshop in the first position.