<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def trim_empty_columns(self):
 """Removes all trailing empty columns."""

    if self.nrows != 0 and self.ncols != 0:
      last_col = -1
      for row in self.rows:
        for i in range(last_col + 1, len(row)):
          if not self.is_cell_empty(row[i]):
            last_col = i
      ncols = last_col + 1
      self.rows = [row[:ncols] for row in self.rows]
      self.ncols = ncols
    return self