Open
Description
Issue Overview
For the file magicattr_start.py, you used the code:
`
def __setattr__(self, name, value):
if name == 'price':
if type(value) is not float:
raise ValueError(
"The price attribute must be a float data type")
return super().__setattr__(name, value)
`
I tried to add an else clause right before the final return statement, to make my code more explicit:
`
def __setattr__(self, name, value):
if name == 'price':
if type(value) is not float:
raise ValueError(
"The price attribute must be a float data type")
else:
return super().__setattr__(name, value)
`
However this throws an error: "AttributeError: 'Book' object has no attribute 'price'".
I tried searching on stackoverflow and using ChatGPT to find out what is the reason behind this, but to no avail.
Could you please help? Thank you!
Metadata
Metadata
Assignees
Labels
No labels