<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_stickiness(self):
 """ Adds stickiness policy to created ELB Returns: dict: A dict of stickiness policies and ports:: example: { 80: "$policy_name" } """

        stickiness_dict = {}
        env = boto3.session.Session(profile_name=self.env, region_name=self.region)
        elbclient = env.client('elb')
        elb_settings = self.properties['elb']
        for listener in elb_settings.get('ports'):
            if listener.get("stickiness"):
                sticky_type = listener['stickiness']['type'].lower()
                externalport = int(listener['loadbalancer'].split(":")[-1])
                policyname_tmp = "{0}-{1}-{2}-{3}"
                if sticky_type == 'app':
                    cookiename = listener['stickiness']['cookie_name']
                    policy_key = cookiename.replace('.', '')
                    policyname = policyname_tmp.format(self.app, sticky_type, externalport, policy_key)
                    elbclient.create_app_cookie_stickiness_policy(
                        LoadBalancerName=self.app, PolicyName=policyname, CookieName=cookiename)
                    stickiness_dict[externalport] = policyname
                elif sticky_type == 'elb':
                    cookie_ttl = listener['stickiness'].get('cookie_ttl', None)
                    policyname = policyname_tmp.format(self.app, sticky_type, externalport, cookie_ttl)
                    if cookie_ttl:
                        elbclient.create_lb_cookie_stickiness_policy(
                            LoadBalancerName=self.app, PolicyName=policyname, CookieExpirationPeriod=cookie_ttl)
                    else:
                        elbclient.create_lb_cookie_stickiness_policy(LoadBalancerName=self.app, PolicyName=policyname)
                    stickiness_dict[externalport] = policyname
        return stickiness_dict