Python Basics: Building Systems With Classes (Quiz)

Avatar image for CB

CB on Nov. 3, 2023

Unsure why isinstance(jack, Dog) returns False. jack is in the Bulldog class which is a subclass of Dog, so should return True?

Avatar image for Bartosz Zaczyński

Bartosz Zaczyński RP Team on Nov. 4, 2023

It does return True, and that’s what the quiz question expects. Are you getting a different result when you run the code?

Avatar image for Lilian Cipciriuc

Lilian Cipciriuc on Jan. 24, 2025

Running the code

bobo = JackRusselTerrier()

is throwing a syntax error

Avatar image for Bartosz Zaczyński

Bartosz Zaczyński RP Team on Jan. 27, 2025

@Lilian Cipciriuc If you’re seeing a syntax error, then it must be caused by an earlier piece of code because the line that you posted appears to be synactically correct. The error’s stack trace should point you in the right direction, though, as it usually includes the offending line of code.

Here’s an example:

>>> def function
  File "<python-input-0>", line 1
    def function
                ^
SyntaxError: expected '('

Become a Member to join the conversation.