Skip to content Skip to sidebar Skip to footer

Create A Box With Text In Center

I want to draw a box around my message. The result to be like this: # # # # # # # # # # # # # # # # # # # # # # # # # # # #

Solution 1:

Just build each line separately:

emptyspace = "                   "
lempty = len(emptyspace)
addS = "Message"
news = "#" + emptyspace + addS + emptyspace + "#"
lnew = len(news)

edge = "# "
mid = "# "
for i in range((lnew / 2 - 1)):
    edge += "# "
    mid += "  "
edge += "#"
mid += "#"

print edge
print mid
print news
print mid
print edge

Post a Comment for "Create A Box With Text In Center"