Answer the question
In order to leave comments, you need to log in
How to assign an object to a method argument in another class?
I started learning OOP and ran into a problem. I am writing a shopping cart program.
class Product:
def __init__(self, name, price):
self.name = name
self.price = price
def get_total(self, units):
result = self.price * units
return result
class Cart:
def __init__(self):
self.list_product = list()
self.units = list()
def add(self, product, units):
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question