For each value in the list, return it, if all the elements of the sublist have length less-than-or-equal-to 6
[x for x in mylist if all(len(y) <= 6 for y in x)]
You can also create a list from the singular string elements, but unclear why you’d want this
>>> simple_list=['apple', 'banana', 'cantaloupe', 'durian']
>>> short_list = [[blist] for blist in simple_list if len (blist) <= 7]
>>> short_list
[['apple'], ['banana'], ['durian']]
1
solved list comprehension remove 2d list (sublist) from list if length is less than 7 [closed]