<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def scan(self, stop_on_first=True, base_ip=0):

 """Scans the local network for TVs."""

        tvs = []

        # Check if base_ip has been passed
        if base_ip == 0:
            # Find IP address of computer pymitv is running on
            sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            sock.connect(("8.8.8.8", 80))
            ip = sock.getsockname()[0]
            sock.close()

            # Get IP and compose a base like 192.168.1.xxx
            ip_parts = ip.split('.')
            base_ip = ip_parts[0] + '.' + ip_parts[1] + '.' + ip_parts[2]

        # Loop through every IP and check if TV is alive
        for ip_suffix in range(2, 256):
            ip_check = '{}.{}'.format(base_ip, ip_suffix)

            if self.check_ip(ip_check):
                tvs.append(ip_check)

                if stop_on_first:
                    break

        return tvs