\_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
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.
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}'")
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.
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}'")\`\`\`
\_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
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}'")
\`\`\`
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.