I'm using Ipython 7.0.1
with Python 3.6.9
I want to right align numbers with the format string mini language. I use 1
and 11
as examples for 1 and 2 digit numbers which I want to pad to 2 characters total.
For zero padding everything works as expected, >
is optional because it is the default:
In [0]: print(f"{1:02d}\n{11:02d}\n{1:0>2d}\n{11:0>2d}")
01
11
01
11
But when I want to pad with spaces it also works as long as I leave the space out so that it defaults to space:
In [1]: print(f"{1:2d}\n{11:2d}\n{1:>2d}\n{11:>2d}")
1
11
1
11
But If I explicitly type out the space, I am surprised by the result:
In [2]: print(f"{1: 2d}\n{11: 2d}\n{1: >2d}\n{11: >2d}")
1
11
1
11
Why is that?