Python3 Programming Snippet - 2 : Squared Text

in #programming7 years ago

I'm sure some fellow Steemit users have seen users on text focused sites like Reddit having comments that are in the format:

GOODBOYE

O                 Y

O                 O

D                 B

B                 D

O                 O

Y                  O

EYOBDOOG

Here's an implementation where you can enter whatever alphanumeric word you'd like to be displayed in above shown example format.

def squareText():

 text = input("Enter string\nNote:It will be converted to uppercase\n").upper()

 for i in range(len(text)):

  for j in range(len(text)):

   if i == 0: #1st row, print normally

    print(text[j], end='')

   elif i == len(text) - 1: #last row, print reverse

    print(text[len(text)-1-j], end='')

   else: #middle rows

    if j == 0:

     print(text[i], end='')

    elif j == len(text) - 1:

     print(text[len(text)-1-i], end='')

    else:

     print(" ", end='')

  print()

Sort:  

Congratulations @notanon! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published your First Post
You made your First Vote
You got a First Vote

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Congratulations @notanon! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Do not miss the last post from @steemitboard:

SteemitBoard Ranking update - Steem Power, Followers and Following added

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @notanon! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.029
BTC 66330.08
ETH 3331.87
USDT 1.00
SBD 2.70