<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_islands(self, show_info=False):
 """ Check the connectivity for the ac system Parameters show_info : bool Show information when the system has islands. To be used when initializing power flow. Returns ------- None """

        if not hasattr(self, 'Line'):
            logger.error('<Line> device not found.')
            return
        self.Line.connectivity(self.Bus)

        if show_info is True:

            if len(self.Bus.islanded_buses) == 0 and len(
                    self.Bus.island_sets) == 0:
                logger.debug('System is interconnected.')
            else:
                logger.info(
                    'System contains {:d} islands and {:d} islanded buses.'.
                    format(
                        len(self.Bus.island_sets),
                        len(self.Bus.islanded_buses)))

            nosw_island = []  # no slack bus island
            msw_island = []  # multiple slack bus island
            for idx, island in enumerate(self.Bus.island_sets):
                nosw = 1
                for item in self.SW.bus:
                    if self.Bus.uid[item] in island:
                        nosw -= 1
                if nosw == 1:
                    nosw_island.append(idx)
                elif nosw < 0:
                    msw_island.append(idx)

            if nosw_island:
                logger.warning(
                    'Slack bus is not defined for {:g} island(s).'.format(
                        len(nosw_island)))
            if msw_island:
                logger.warning(
                    'Multiple slack buses are defined for {:g} island(s).'.
                    format(len(nosw_island)))

            if (not nosw_island) and (not msw_island):
                logger.debug(
                    'Each island has a slack bus correctly defined.')