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.

0

1 Answer 1

2

Try:

x = 20

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

Prints:

         |          
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.