You can use formatwith >to justify correctly
N = 10
for i in range(1, N+1):
print('{:>10}'.format('#'*i))
Output
You can programmatically determine how far from the right alignment using rjust.
for i in range(1, N+1):
print(('#'*i).rjust(N))
source
share