nit: I know this code is copy-pasted from before, but it's better in Python to do `isinstance(courses, dict)` in case `courses` is a subclass of `dict`.