def list_of_true_keys(d):
 ret = []
 for key in d:
  if d[key]:
   ret.append(key)
 return ret

def list_of_true_keys ( d ) : ret = [ ] for key in d : if d [ key ] : ret . append ( key ) return ret
maintain a list of valid true keys .