I'm trying to write a code to have a phrase print vertically and it needs to be printed a certain away. I'm having the user input a string but I need the output to look a certain way with spaces. I have some of the code written already:
def main():
#have user input phrase
phrase = input("Enter a phrase: ")
print() # turnin
print() #blank line
print("Original phrase:",phrase)
print() # blank line
word_l = phrase.split()
word_a = len(word_l)
max_len = 6
for i in range(word_a):
length = len(word_l[i])
if length < max_len:
print(len(word_l[i]) * " ",end="")
I need to have 2 loops inside each other for the next part but I don't believe the above loop and if statement are correct. So the say the user inputs the phrase: Phil likes to code. I need the output to look like:
P l t c
h i o o
i i d
l k e
e
s
The spaces in between the words are the spaces as if the letters were there including one space. I can't use any imports and the only function I can use is split. I need to have a for loop with an if statement there and then I need another for loop with a for loop inside of that. Would really appreciate any help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…