Back to Freecodecamp

Step 6

curriculum/challenges/english/blocks/workshop-salary-tracker/68c281cecda94ba2c6838e17.md

latest748 B
Original Source

--description--

Now that you defined a getter for name, you can access the _name attribute through the name property. So print charlie_brown.name to the console.

--hints--

You should print charlie_brown.name to the console.

js
({ test: () => assert(runPython(`_Node(_code).has_stmt("print(charlie_brown.name)")`)) })

--seed--

--seed-contents--

py
--fcc-editable-region--
class Employee:
    def __init__(self, name, level):
        self._name = name
        self._level = level

    def __str__(self):
        return f'{self._name}: {self._level}'

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

charlie_brown = Employee('Charlie Brown', 'trainee')
print(charlie_brown)
--fcc-editable-region--