Home > Software design >  How to print vertically from bottom?
How to print vertically from bottom?

Time:11-08

how do i get the letters to print from bottom up?
input = 'mary is happy'

current output : 
m  i  h
a  s  a
r     p
y     p
      y

desired output:
       h
 m     a
 a     p
 r  i  p
 y  s  y

CodePudding user response:

user_input = "Mary is happy"

words = user_input.split(" ")      # ["Mary", "is", "happy"]
biggest = max(words, key=len)      # get the biggest word

# pad each word to match the size of the biggest word
# --> words = [" Mary", "   is", "happy"]
words = [word.rjust(len(biggest)) for word in words]

for c in zip(*words):
    # c is a tuple of the i-th character for every word
    print(*c)

CodePudding user response:

enter image description here

enter image description here

enter image description here

  • Related