def build_sponsor_list(sponsor_atags):
 sponsors = []
 house_chief = senate_chief = None
 spontype = 'cosponsor'
 for atag in sponsor_atags:
  sponsor = atag.text
  if ('house' in atag.attrib['href'].split('/')):
   chamber = 'lower'
  elif ('senate' in atag.attrib['href'].split('/')):
   chamber = 'upper'
  else:
   chamber = None
  if ((chamber == 'lower') and (house_chief is None)):
   spontype = 'primary'
   official_spontype = 'chief'
   house_chief = sponsor
  elif ((chamber == 'upper') and (senate_chief is None)):
   spontype = 'primary'
   official_spontype = 'chief'
   senate_chief = sponsor
  else:
   spontype = 'cosponsor'
   official_spontype = 'cosponsor'
  sponsors.append((spontype, sponsor, chamber, official_spontype))
 return sponsors

def build_sponsor_list ( sponsor_atags ) : sponsors = [ ] house_chief = senate_chief = None spontype = 'cosponsor' for atag in sponsor_atags : sponsor = atag . text if ( 'house' in atag . attrib [ 'href' ] . split ( '/' ) ) : chamber = 'lower' elif ( 'senate' in atag . attrib [ 'href' ] . split ( '/' ) ) : chamber = 'upper' else : chamber = None if ( ( chamber == 'lower' ) and ( house_chief is None ) ) : spontype = 'primary' official_spontype = 'chief' house_chief = sponsor elif ( ( chamber == 'upper' ) and ( senate_chief is None ) ) : spontype = 'primary' official_spontype = 'chief' senate_chief = sponsor else : spontype = 'cosponsor' official_spontype = 'cosponsor' sponsors . append ( ( spontype , sponsor , chamber , official_spontype ) ) return sponsors
return a list of tuples .