How in python to transfer a variable to the place "2" in a format construction?

 print("{0:.2f}".format(7.18345)) 

To make it like this:

 print("{0:.(a)f}".format(7.18345)) 

    1 answer 1

    The language in the format-template supports nested substitutions:

     print("{:.{precision}f}".format(7.18345, precision=2)) # -> 7.18 
    • It works :) Thank you. - Oleg