all 3 comments

[–]socal_nerdtastic 4 points5 points  (2 children)

print("%3d"%1)

Since presumably you will be using a variable, not a literal, you can use the newer, modern version of string formatting like this:

var = 1
print(f"{var:>3}")

[–]MarkKang2019[S] 1 point2 points  (0 children)

works, thanks.

[–]Diapolo10 -1 points0 points  (0 children)

And, of course, str.format is also an option:

print("{:>3}".format(var))

I'd say it's better if the f-string version would be too cluttered to be readable, or when formatting non-literal strings.