1

I would like to replace "10" in the example below with a variable, but I haven't found any examples that work.

print(f'{"|":^10s}')

Can you suggest a method to set x=10, then have:

print(f'{"|":^xs}')

Thank you.

Xukrao
  • 8,003
  • 5
  • 26
  • 52
user2571504
  • 53
  • 1
  • 6

1 Answers1

2

Try:

x = 20

print(f'{"|":^{x}s}')

Prints:

         |          
Andrej Kesely
  • 168,389
  • 15
  • 48
  • 91