I know that when I use
"%2d"%(x)
I will get a string of x and in at least size of 2, and if the length of x is shorter than 2 I will get spaces before it. But how can I give the 2 as a variable too? For example:
"%nd"%(2,1)
' 1'
Is it possible in Python? Or do I need to create a loop for it?
'%*d' % (n, x)should work'{:>{}}'.format(x, n)