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
Post a Comment