Skip to content
Advertisement

Python spacing and aligning strings

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

Currently have it coded like this, just using spaces…

JavaScript

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

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.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement