0

I'm trying to create something like this as terminal output:

VALUE A                       VALUE B                    INT C
alpha                         bravo                      69420
charlie                       delta                      69421
echo                          foxtrot                    69422

I have a snippet of code from a different script to print the correct number of spaces (in this example, make it so that there are spaces after the printed value until col 64.)

print(header)
for f in files:
    fLen = len(f)
    fiLen = (fLen - 64)
    finLen = (fiLen - fiLen - fiLen)
    print(f+" "*(fiLen))

I'm not sure how to:

  • Get this same operation done with less operation to keep it "pythonic",
  • Scale this to multiple columns (like to automatically generate a lot more rows of that example output.
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
lemuria
  • 59
  • 1
  • 9
  • Is there a maximum width per column, or do you want the column widths to be dependent on the longest string per column? – ddejohn Sep 25 '21 at 04:02
  • 1
    I strongly recommend renaming your variables to something both more distinct from each other and also more descriptive. You have three variables `fLen`, `fiLen` and `finLen` and that makes it very difficult to read your code. – ddejohn Sep 25 '21 at 04:03
  • So I take it you're from `finLend`? :-) – rv.kvetch Sep 25 '21 at 04:18

0 Answers0