Build a Salary Tracker - Step 14

Tell us what’s happening:

def init(self, name, level):
if not isinstance(name, str) or not isinstance(level, str):
raise TypeError(“‘name’ and ‘level’ attribute must be of type ‘str’”)

Error Your if statement should raise a TypeError with the message ‘name’ and ‘level’ attribute must be of type ‘str’.

Your code so far

class Employee:

# User Editable Region

    def __init__(self, name, level):
        if not isinstance(name, str) or not isinstance(level, str): 
            raise TypeError("'name' and 'level' attribute must be of type 'str'")
        self._name = name
        self._level = level

# User Editable Region

    def __str__(self):
        return f'{self.name}: {self.level}'

    def __repr__(self):
        return f"Employee('{self.name}', '{self.level}')"

    @property
    def name(self):
        return self._name

    @property
    def level(self):
        return self._level

charlie_brown = Employee('Charlie Brown', 'trainee')
print(charlie_brown)

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Challenge Information:

Build a Salary Tracker - Step 14

You are missing a period at the end of error message.

those always get me.

Pro tip with these challenges and tests. They want everything in the highlighted text included. Puncation, Spaces, Quotations. All of it.

Happy Coding.