<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_ports(self, scan_id, target):
 """ Get a scan's ports list. If a target is specified it will return the corresponding port for it. If not, it returns the port item of the first nested list in the target's list. """

        if target:
            for item in self.scans_table[scan_id]['targets']:
                if target == item[0]:
                    return item[1]

        return self.scans_table[scan_id]['targets'][0][1]