def filter_list(complete_list, browsers):
 table = {}
 for entry in complete_list:
  candidate = (entry[1].text_content(), entry[2].text_content())
  for name in browsers:
   found = False
   if (name.lower() in candidate[1].lower()):
    for version in browsers[name]:
     if (version.lower() in candidate[1].lower()):
      if (table.get(name) is None):
       table[name] = []
      table[name].append(candidate)
      browsers[name].remove(version)
      found = True
      break
   if found:
    break
 return table

def filter_list ( complete_list , browsers ) : table = { } for entry in complete_list : candidate = ( entry [ 1 ] . text_content ( ) , entry [ 2 ] . text_content ( ) ) for name in browsers : found = False if ( name . lower ( ) in candidate [ 1 ] . lower ( ) ) : for version in browsers [ name ] : if ( version . lower ( ) in candidate [ 1 ] . lower ( ) ) : if ( table . get ( name ) is None ) : table [ name ] = [ ] table [ name ] . append ( candidate ) browsers [ name ] . remove ( version ) found = True break if found : break return table
filter the received list based on a look up table .