'How to align string after variable text length
I'm looking to add padding after text to align a column of strings:
example output:
a: ***
aa: ***
aaa: ***
I've tried adding adding a left and right adjust to format, but it seems to make the adjustment after the :
s = 'a: {:>10}\n' \
'aa: {:>10}\n' \
'aaa: {:>10}'
print(s.format('***', '***', '***'))
which outputs
a: ***
aa: ***
aaa: ***
Is there any way to account for the variable length of the a, aa, aaa
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
