0
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. Whenever I try to run the code, it does not return anything.

3
  • 2
    Your last 3 functions need to return something. Commented Oct 17, 2020 at 6:58
  • Which part is wrong? Commented Oct 17, 2020 at 6:58
  • check_inventory() needs to either return or print something Commented Oct 17, 2020 at 6:59

1 Answer 1

1

Firstly there is no inheritance in your code. It is just a class and object code. Second you need to return data from your methods.

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):
        return list(self.bin.keys())

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

    def check_inventory(self):
        return 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")
    inventory = bin1.check_inventory()
    print(inventory)
    ids = bin1.check_ids()
    print(ids)
    names = bin1.check_names()
    print(names)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.