dictionary - The list with most elements -


i have list dictionary elements. each dictionary has entry called type. type field represents list. simplest/pythonic way of obtaining list elements?

programmes_by_type = [] programmes_by_type.append({'type' : [1, 2, 3]}) programmes_by_type.append({'type' : [2, 5]}) programmes_by_type.append({'type' : [3]}) programmes_by_type.append({'type' : [11, 2, 6, 7]}) 

given previous example should return [11, 2, 6, 7] list.

max([option['type'] option in programmes_by_type], key=len) 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -