Cloud Stack Ninja

class Bin():
    def __init__(self):
        self.bin = {}

    def add_to_bin(self, medId , medName):
        self.bin[medId] = medName

    def remove_by_id(self, id):
        self.bin.pop(id)

    def clean_bin(self):
        self.bin.clear()

    def check_ids(self):
        list(self.bin.keys())

    def check_names(self):
        list(self.bin.values())

    def check_inventory(self):
        list(self.bin.items())


if __name__ == "__main__":
    bin1 = Bin()
    bin1.add_to_bin(100, "advil")
    bin1.add_to_bin(200, "tylenol")
    bin1.add_to_bin(300, "pepto-bismol")
    bin1.check_inventory()

What am I doing wrong? I am so confused. I am trying to create a medical storage system with multiple dictionaries.



Read more here: https://stackoverflow.com/questions/64399793/python-why-my-inheritence-does-not-work

Content Attribution

This content was originally published by Berker Erdini at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: