I am writing a simple Checkout program in python My checkout class is
Class Checkoutregister
product1 = Product(510, 'milk', 6)
product2 = Product(511, 'coke', 3)
product3 = Product(512, 'chicken', 10)
product4 = Product(513, 'shirt', 40)
product5 = Product(514, 'kitkat', 4)
list=[]
This is my product class
class Product:
def __init__(self,barcode,name,price):
self.barcode=barcode
self.name=name
self.price=price
I am writing a function to insert the products to the list and print the list..but I am getting problem while printing the list
def insertProduct():
Checkoutregister.list.insert(0,Checkoutregister.product1)
print Checkoutregister.list
The print statement prints like
[<Product.Product instance at 0x04AEB6C0>]
how can I print the list and how can I iterate around the list to print all the inserted products in the list when I add all the products in the list