Format in python by variable length

Currently your code interpreted as below:

for i in range(6, 0, -1):
    print ( ("{0:>"+str(i))     +     ("}".format("#")))

So the format string is constructed of a single "}" and that's not correct. You need the following:

for i in range(6, 0, -1):
    print(("{0:>"+str(i)+"}").format("#"))

Works as you want:

================ RESTART: C:/Users/Desktop/TES.py ================
     #
    #
   #
  #
 #
#
>>> 

Much simpler : instead of concatenating strings, you can use format again

for i in range(6, 0, -1): 
    print("{0:>{1}}".format("#", i))

Try it in idle:

>>> for i in range(6, 0, -1): print("{0:>{1}}".format("#", i))

     #
    #
   #
  #
 #
#

Or even fstring (as Florian Brucker suggested - I'm not an fstrings lover, but it would be incomplete to ignore them)

for i in range(6, 0, -1): 
    print(f"{'#':>{i}}")

in idle :

>>> for i in range(6, 0, -1): print(f"{'#':>{i}}")

     #
    #
   #
  #
 #
#