My code is as below:
and it is wrong because
your last two lines shouldn't be inside of the cass definition.
Thank you very much for kindly reply
I had the same problem as SUGARKAKA and you solved it.
Could you explain why this needs to be outside the class please?
The class definiton is like a template for objects.
You can only create an object of a certain class if that class is already defined. If you try to create an instance of ShoppingCart inside of ShoppingCart's definition, Python doesn't know yet what ShoppingCart is, because it is still "reading" the definition.