class Container(): def __init__(self, max, y=0, g=0, b=0): self.y, self.g, self.b = y, g, b self.max = max def empty(self): self.y, self.g, self.b = 0, 0, 0 def status(self): return [self.y, self.g, self.b] def add(self, trash): my_trash = [self.y, self.g, self.b] leftovers = [0, 0, 0] for i in range(0, len(trash)): while(my_trash[i] < self.max and trash[i] > 0): my_trash[i] += 1 trash[i] -= 1 self.y, self.g, self.b = my_trash result = [0, 0, 0] for i in range(0, len(trash)): result[i] = trash[i] - leftovers[i] return result