Nov-26-2020, 01:18 PM
(Nov-24-2020, 11:38 PM)bowlofred Wrote: Use a formatting package. As an example, you could look at tabulate, but there are several others.
Otherwise, you need to calculate the size of your fields yourself and enforce that size with formatting commands.
table = [["A", "B", "C"], ["D", "Epsilon", "Foxtrot city"], ["South Mangrove", "T", "U"]] Thanks for that. I just get some thing a bit different list_a=[[1,2,3,4,5], ['d','h','f','s','g']] #a=0, a=1,a=2, a=3, a=4,a=5 for row in list_a: print("{:15} {:15} {:15} {:15}{:15} ".format(*row))]]) [output] 1 2 3 4 5 d h f s g any idea why 1 and d are not in line and the rest? Thanks. [output]-------------- ------- ------------ A B C D Epsilon Foxtrot city South Mangrove T U -------------- ------- ------------[/output] Manual example: [python]table = [["A", "B", "C"], ["D", "Epsilon", "Foxtrot city"], ["South Mangrove", "T", "U"]] for row in table: print("{:15} {:15} {:15}".format(*row))
Output:A B C D Epsilon Foxtrot city South Mangrove T U