I create some code to simulate a vending machine, I want to know what is in the machine, but I do not manage to get there.
This is my output when I print(machine):
[<__main__.Vending_slot object at 0x7fd59f53db38>,
<__main__.Vending_slot object at 0x7fd59f53dba8>,
<__main__.Vending_slot object at 0x7fd59f53db00>,
<__main__.Vending_slot object at 0x7fd59f53dbe0>]
Code:
class Vending_slot:
def __init__(self, product, stock, price):
self.product = product
self.stock = stock
self.price = price
def dispense_item(self):
print(f"You bought a {self.items[0]}.")
self.items = items[1]
machine = []
machine.append(Vending_slot("A1", ["Coke","Coke","Coke"], 1.5))
machine.append(Vending_slot("A2", ["Water","Water","Water"], 0.5))
machine.append(Vending_slot("B1", ["Twix","Twix","Twix"], 1))
machine.append(Vending_slot("B2", ["Gum","Gum","Gum"], 0.8))
print(machine)