I am trying to add spacing to align text in between two strings vars without using " "
to do so
Trying to get the text to look like this, with the second column being aligned.
JavaScript
x
4
1
Location: 10-10-10-10 Revision: 1
2
District: Tower Date: May 16, 2012
3
User: LOD Time: 10:15
4
Currently have it coded like this, just using spaces…
JavaScript
1
2
1
"Location: " + Location + " Revision: " + Revision + 'n'
2
I tried working with string.rjust
& srting.ljust
but to no avail.
Suggestions?
Advertisement
Answer
You should be able to use the format method:
JavaScript
1
2
1
"Location: {0:20} Revision {1}".format(Location, Revision)
2
You will have to figure out the format length for each line depending on the length of the label. The User
line will need a wider format width than the Location
or District
lines.