Home > other >  Placing two strings in center of page for Python on the same line
Placing two strings in center of page for Python on the same line

Time:06-02

I wanted to place the two strings, "Your name is " and name variable in the center of the page but I tried using .center(165) and rjust(165//2) commands but does not seem to work. My code:

name=input("your name :".rjust(165//2))
print("your name is "   name).rjust(165//2)

which does not work

what my desired outcome:

                                      Your name: example
                                     Your name is example

CodePudding user response:

name=input("your name :".rjust(165//2))
print(f"your name is {name}".rjust(165//2))
  • Related