I have a list of lists with the structure [[s: str, s: str, s: str]]
and there can be any number of items (lists) inside of it.
I want to print this cleanly in columns like so:
FirstFirst FirstSecond FirstThird
SecondFirst SecondSecond SecondThird
ThirdFirst ThirdSecond ThirdThird
foo bar foobar
So, despite having different lengths, each item in the sublists are left-justified in a column.
I have already tried very complex list comprehensions like
lists = [['FirstFirst', 'FirstSecond', 'FirstThird'],
['SecondFirst', 'SecondSecond', 'SecondThird'],
['ThirdFirst', 'ThirdSecond', 'ThirdThird'],
['foo', 'bar', 'foobar']]
[print(f'{_[0]}{" " * (15 - len(_[0]))}{_[1]}{" " * (30 - len(_[0] + _[1] + " " * (15 - len(_[0]))))}{_[2]}') for _ in lists]
While this does work, it is very bruteforce-ish.
What's worse is that this list comprehension is not at all scalable. If I want to add another string to each item in the sublists, I'll have to add a lot more to my list comprehension to make it all still work. Also, everything is foiled if I want two lists to have different lengths.
What is a better way of doing this?