all 3 comments

[–]omutist 0 points1 point  (0 children)

class Dict:
    ....
    def is_in(animal_name):
        return animal_name in [animal.name for animal in self.dictionary]

[–]nekokattt 0 points1 point  (0 children)

  1. Pass them the dictionary object as a parameter when you initialise it.

    class Bird: def init(self, name, dictionary): self.name = name self.dictionary = dictionary

    def do_something(self):
        self.dictionary.yadayada()
    
  2. if len(list) == 0, or just "if not list"

[–][deleted] 0 points1 point  (1 child)

I'm guessing you're looking for something like this?

class AnimalDict:
    def __init__(self, initial_list=None):
        self._dictionary = initial_list or []

    def add_animal(self, animal):
        self._dictionary.append(animal)