Loading exercise...

Exercise: Write Employee CSV

Avatar image for gunnarpruss

gunnarpruss on Nov. 6, 2026

Hi Joe, the tests assume the existence of a “birthday month” field which is part of the previous video, but is not asked for in the instructions above. The error message might help to solve the issue, but it’s still confusing. Anyways, thanks for the course!

Avatar image for Bartosz Zaczyński

Bartosz Zaczyński RP Team on Nov. 9, 2026

@gunnarpruss thanks for flagging this, you’re right. The tests call write_employees() with dictionaries that include an extra "birthday month" key, but the instructions only show name and department. A hardcoded fieldnames=["name", "department"] then raises ValueError: dict contains fields not in fieldnames: 'birthday month'.

The intended approach is to take the field names from the dictionaries themselves, so the function works with any set of keys:

writer = csv.DictWriter(csv_file, fieldnames=employees[0].keys())

I’ve updated the instructions to make this explicit, and the tests now show a clearer error message when the field names don’t match. Glad you enjoyed the course.

Become a Member to join the conversation.