-1

Is there a way to get this to work? Have a full box and then have the name displayed in the center?

users_name = input (str(" Enter Your Name: "))
print("**************************************************")
print("*                                                *")
print("*                                                *")
print("*                                                *")
print("*                  users_name                    *")
print("*                                                *")
print("*                                                *")
print("*                                                *")
print("*                                                *")
print("*                                                *")
print("*                                                *")
print("**************************************************")
MAMA
  • 13
  • 4
  • Duplicate of https://stackoverflow.com/questions/12169839/which-is-the-preferred-way-to-concatenate-a-string-in-python – esqew Oct 04 '22 at 02:46

2 Answers2

4

Use a formatting string to center the string in a specified width:

print(f"*{users_name:^48}*")

Python Docs:

Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251
0

You can use f-strings to replace the users_name in the text. Please see the link below for more details.

https://www.geeksforgeeks.org/formatted-string-literals-f-strings-python/

ScottC
  • 157
  • 6