---
id: 69b023541591abde576613db
title: Step 27
challengeType: 20
dashedName: step-27
---

# --description--

Now that the `level` setter is created, update `__init__` to use `self.level = level` instead of `self._level = level`. This delegates `level` assignment through the setter, and validation will be added to it in the next step.

Also, remove the `if not isinstance(level, str)` check from `__init__` since the setter will handle that validation in the next step.

# --hints--

Your `__init__` method should use `self.level = level` instead of `self._level = level`.

```js
({ test: () => assert(runPython(`_Node(_code).find_class("Employee").find_function("__init__").has_stmt("self.level = level")`)) })
```

Your `__init__` method should not contain the `isinstance(level, str)` check.

```js
({ test: () => assert(runPython(`not _Node(_code).find_class("Employee").find_function("__init__").find_if("not isinstance(level, str)").find_body().has_stmt("raise TypeError(\\"'level' attribute must be of type 'str'.\\")")`)) })
```

# --seed--

## --seed-contents--

```py
class Employee:
    _base_salaries = {
        'trainee': 1000,
        'junior': 2000,
        'mid-level': 3000,
        'senior': 4000,
    }

    def __init__(self, name, level):
--fcc-editable-region--
        if not isinstance(level, str):
            raise TypeError("'level' attribute must be of type 'str'.")
        if level not in Employee._base_salaries:
            raise ValueError(f"Invalid value '{level}' for 'level' attribute.")
        self.name = name
        self._level = level
--fcc-editable-region--
        self._salary = Employee._base_salaries[level]

    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

    @name.setter
    def name(self, new_name):
        if not isinstance(new_name, str):
            raise TypeError("'name' must be a string.")
        self._name = new_name
        print(f"'name' updated to '{self.name}'.")

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

    @level.setter
    def level(self, new_level):
        self._level = new_level

    @property
    def salary(self):
        return self._salary

charlie_brown = Employee('Charlie Brown', 'trainee')
print(charlie_brown)
print(f'Base salary: ${charlie_brown.salary}')

```
