<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_sensor(self, sensor):
 """ Format a sensor value. If pango is enabled color is per sensor. """

        current_val = sensor.current
        if self.pango_enabled:
            percentage = self.percentage(sensor.current, sensor.critical)
            if self.dynamic_color:
                color = self.colors[int(percentage)]
                return self.format_pango(color, current_val)
        return current_val