So I have this simple print
statement:
print "%-10s %s" % ("test","string")
which prints the desired output:
test string
I'm trying to figure out the correct syntax for a case where the fill value is a variable. Example:
w = 10
print "%-s %s" % (w,"test","string")
So %-s
should be replaced with what to accommodate the fill value?
If I remember it correctly, the syntax is similar to %-xs
where x
is replaced by a an int variable. I might be mistaken though.
Note
I know this question is probably duplicated since this is really elementary string formatting issue. However, after some time of searching for the right syntax I gave up.