<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register_service_into_servicegroups(service, servicegroups):
 """ Registers a service into the service groups declared in its `servicegroups` attribute. :param service: The service to register :type service: :param servicegroups: The servicegroups container :type servicegroups: :return: None """

        if hasattr(service, 'service_description'):
            sname = service.service_description
            shname = getattr(service, 'host_name', '')
            if hasattr(service, 'servicegroups'):
                # Todo: See if we can remove this if
                if isinstance(service.servicegroups, list):
                    sgs = service.servicegroups
                else:
                    sgs = service.servicegroups.split(',')
                for servicegroup in sgs:
                    servicegroups.add_member([shname, sname], servicegroup.strip())