0
cant seem to find out whats wrong here
3 Réponses
+ 2
You can't mix defining the object and calling its methods as here:
item1=Product(400, "50 inch, Flat screen", 100 , "Samsung").displayInfo().addTax(0.06).sell().itemReturn("Opened")
Try instead:
# define the object
item1=Product(400, "50 inch, Flat screen", 100 , "Samsung")
#call the methods you need
item1.displayInfo()
item1.addTax(0.06)
item1.sell()
item1.itemReturn("Opened")
+ 1
Oh, I've got. There is a trouble with indenting.
To get calling the methods in one line as in your code all the ones must return the reference to the object (i.e. 'return self') . In your code it is fulfilled only for 'displayInfo' method. In other methods 'return self' is inside of 'if... else' block and doesn't executed in all cases.
So you need to correct the indents of 'return self' lines.
0
not quite clear with the explanation . this is the main error :
AttributeError: 'NoneType' object has no attribute 'itemReturn'