Build a salary tracker step 22

class Employee:

\_base_salaries = {

    'trainee': 1000,

    'junior': 2000,

    'mid-level': 3000,

    'senior': 4000,

}



def \__init_\_(self, name, level):

    if not (isinstance(name, str) and isinstance(level, str)):

        raise TypeError("'name' and '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

    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

    \# This line fulfills the requirement:

    print(f"'name' updated to '{new_name}'")

    

@property

def level(self):

    return self.\_level



@property

def salary(self):

    return self.\_salary

charlie_brown = Employee(‘Charlie Brown’, ‘trainee’)

print(charlie_brown)

print(f’Base salary: ${charlie_brown.salary}')

I updated the @name.setter but it still gives this intruction “You should print 'name' updated to 'new_name'., where new_name should be replaced by the new value of _name.”

Please share a link to the step, also please post again your code following this guide to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

thank you for the link! now can you make your code readable please?

@name.setter

def name(self, new_name):

    if not isinstance(new_name, str):

        raise TypeError("'name' must be a string.")

    self.\_name = new_name

    \# This line fulfills the requirement:

    print(f"'name' updated to '{new_name}'")

Is this correct?

Please post again your code following this guide to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

```@name.setter

def name(self, new_name):

    if not isinstance(new_name, str):

        raise TypeError("'name' must be a string.")

    self.\_name = new_name

    \# This line fulfills the requirement:

    print(f"'name' updated to '{new_name}'")\`\`\`

Sorry, I’m sharing this first time.

Why you aren’t reviewing the code by using this link?

Can I share the code by another way?

hy is python easy language?

Yes, it is an easy language

that is the link to the challenge, your code is not at that link

I am waiting you post the code correctly formatted so I can test it and see what’s wrong

please use backticks like this:

```
your code here
```

the abckticks need to go on their own line

```
class Employee:

\_base_salaries = {

    'trainee': 1000,

    'junior': 2000,

    'mid-level': 3000,

    'senior': 4000,

}



def \__init_\_(self, name, level):

    if not (isinstance(name, str) and isinstance(level, str)):

        raise TypeError("'name' and '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

    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 '{new_name}'")

    

@property

def level(self):

    return self.\_level



@property

def salary(self):

    return self.\_salary

charlie_brown = Employee(‘Charlie Brown’, ‘trainee’)

print(charlie_brown)

print(f’Base salary: ${charlie_brown.salary}')
```

```

@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 '{new_name}'")

    \`\`\`

This is the part of code which gives an error.

it’s still not being formatted properly, if the backticks don’t work, please select all your code and use the </> button to format it in a code block

I am sure you have not written all those \, but as it is I can’t test your code

make sure you have all the quotes here

and next time, please use the button to get help so you don’t need to write the backticks yourself

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

the answer is
removed

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.