I have a 2D array (I know it is strictly a list of list, but for my purposes, the term 2D array is fine to use) called results full of strings that I want to display in a nice "lined-up" format. Bear in mind that I really don't want to use any imported modules here.
My first attempt of:
for i in range (len(results)):
line = results[i]
print(line[0].ljust(30), line[1], line[2])
made everything incredibly jarred due to letters (and punctucation etc.) being different widths.
My second attempt of:
for i in range (len(results)):
line = results[i]
foo = line[0]
foo = foo.ljust(len(foo)+(7-len(foo)//9), "\t")
print(foo, line[1], line[2])
worked a lot better, however for around 1 in 10 lines (basically any string with length +/- 1 a multiple of 9), it would add one too many or one too little tabs.
What would be the best way of going about this problem?