How do I create an instance of ShoppingCart called my_cart?


#1

Question

How do I create an instance of ShoppingCart called my_cart?

Answer

To create your own instance of ShoppingCart, you do not need to add any code inside of the existing class ShoppingCart code block. Rather, we need to add to the end of the program, completely unindented, the new object and then use that object.
We create an object like this:
my_object = ClassName("parameters")
Then we use an object’s method like this:
my_object.method_name("parameters")


FAQ: Learn Python - Introduction to Bitwise Operators - It's Not All Animals and Fruits