如何从底部垂直打印?
How to print vertically from bottom?
如何让字母自下而上打印?
输入 = '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
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)
enter image description here
enter image description here
enter image description here
如何让字母自下而上打印?
输入 = '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
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)
enter image description here
enter image description here
enter image description here