Python f-string format specifiers: Padding and aligning columns

Python f-string format specifiers: Padding and aligning columns

Use Python f-strings and format specifiers to make quick-and-dirty tables:

d = {'a':10, 'bcd': 2, 'e': 3456}
for key, value in d.items():
    print(f'{key:.<5}{value:.>5}')

Output:

a…….10
bcd……2
e…..3456