I have a set which looks like
set(['A', 'BF', 'B', 'BA', 'ABF', 'AF', 'F', 'BFA', 'AFB', 'BAF', 'FA', 'FB', 'AB', 'FAB', 'FBA'])
and I'm trying to get all Strings which has the smallest length into a list I tried using
print min((element for element in getParts(working_scheme,k)), key=len)
which just prints A
but I need ['A', 'B', 'F']
Ho can I accomplish this?
Something like
To split it up
min_len = min( [ len(x) for x in a_set ] )
returns the minimum of the lengths.[ x for x in a_set if len(x) == min_len ]
List comprehension, returns a list of elements which has length equals tomin_len