Is it possible to use a variable inside of a Python string formatting specifier?
I have tried:
display_width = 50 print(\'\\n{:^display_width}\'.form
Python f-string is more flexible.
>>> display_width = 50 >>> display_content = "some text here" >>> print(f'\n{display_content:^{display_width}}') some text here