human
I am working on the file "FiveThirtyEightRiddler/2017-04-14/2017-04-26-empty_court_seats.ipynb".
The first task is:
Our lass class is Bench.  This class will represent the bench that contains the Justices currently on the Supreme Court.  When the Bench is first formed, it will be empty.  We care about modifying the Bench in a few ways:

Filling all available seats with judges of a certain party (fill_seats).
Adding years to determine if judges have vacated their seats (add_years).
Getting the composition of the court at a particular year, used for displaying the data later (breakdown).

Empty seats in the court are represented by None, and judges are removed when they have <= 0 years left in their term.
Can you write Python code for it?

Write me a Python code to determine if judges have vacated their seats (add_years)?
assistant
#Here is Python code to determine if judges have vacated their seats (add_years).

class Bench:
    
    SIZE = 9
    
    def __init__(self):
        self.seats = [None] * self.SIZE
    
    def fill_seats(self, party):
        # loop through all seats
        for i in range(self.SIZE):
            if self.seats[i] is None:
                # if seat is empty, add new 
                # justice of the correct party
                self.seats[i] = Justice(party)
                
    def add_years(self, num_years):
        for i in range(self.SIZE):
            if self.seats[i] is not None:
                # for occupied seats, remove the given
                # number of years from their remaining
                # term.  If their term is less than 0
                # this means their seat should now
                # be empty again.
                self.seats[i].term -= num_years
                if self.seats[i].term <= 0:
                    self.seats[i] = None
    
    def breakdown(self):
        c = Counter([s.party.name if s is not None else "" for s in self.seats])

        return tuple(c[k] if k in c else 0 for k in [""] + [e.name for e in Party])
    
    def __repr__(self):
        return "\n".join(map(str,self.seats))