Now we'll add behavior to Flight to allocate seats to passengers. To keep this simple, a passenger will simply be a string name:
class Flight: # ... def allocate_seat(seat, passenger): """Allocate a seat to a passenger. Args: seat: A seat designator such as '12C' or '21F'. passenger: The passenger name. Raises: ValueError: If the seat is unavailable. """ rows, seat_letters = self._aircraft.seating_plan() letter = seat[-1] if letter not in seat_letters: raise ValueError("Invalid seat letter {}".format(letter)) row_text = seat[:-1] try: row = int(row_text) except ValueError: raise ValueError("Invalid seat row {}".format(row_text)) if row not in rows: raise ValueError("Invalid row number {}".format(row)) if self._seating[row][letter] ...