I've got a list of strings and I'm trying to make a list of lists of strings by string length.
i.e.
['a', 'b', 'ab', 'abc']
becomes
[['a', 'b'], ['ab'], ['abc']]
I've accomplished this like so:
lst = ['a', 'b', 'ab', 'abc']
lsts = []
for num in set(len(i) for i in lst):
lsts.append([w for w in lst if len(w) == num])
I'm fine with that code, but I'm trying to wrap my head around comprehensions. I want to use nested comprehensions to do the same thing, but I can't figure out how.