您好我正在尝试创建 Mad lib 生成器,但输出未正确对齐。任何人请帮助我。我的代码是
GirlsName=input("A girl's name :")
Number=input("A number :")
Emotion=input("An emotion :")
Place=input("A place :")
BoysName=input("A boy's Name :")
AnotherNumber=input("Another Number :")
NumLessFifty=input("A Number Less than 50 :")
MoreNumber=input("One more number :")
ReindeerName=input("A Reindeer's Name :")
AnotherEmotion=input("Another Emotion :")
Action=input("What you want to do build story or start over:")
if(Action=="build"):
###Mad Lib: The Christmas Surprise###
print("STORY THE CHRISTMAS SURPRISE")
Story="""{0}woke up one Christmas Day to find that she had no presents!
On the end of her bed she found a letter from {1} of Santa's eleves.
It said that Santa was very {2}.
After she had read the letter, She found herself being whisked off to the {3}.
There she met an elf whose name was {4}. He said that he was Santa's helper.
Because Santa was happy, {0} had to deliver all {5} presents to everyone around the world before they woke up.
{8} was in front and off they went.
It was a hard job but in the end they did it in {6} minutes.
When she arrived back home, she found {7} on her bed. She was so {9}."""
newstring=Story.format(GirlsName,Number,Emotion,Place,BoysName,AnotherNumber,NumLessFifty,MoreNumber,ReindeerName,AnotherEmotion)
print(newstring.rjust(10))
我得到的输出是
故事圣诞节惊喜莉莉在圣诞节醒来发现她没有礼物!在她的床尾,她发现了来自圣诞老人的 2 位成员的一封信。它说圣诞老人很高兴。读完信后,她发现自己被带到了公园。在那里,她遇到了一个名叫约翰的精灵。他说他是圣诞老人的帮手。因为圣诞老人很开心,莉莉必须在全世界所有人醒来之前将所有 37 件礼物都送到他们手上。基拉在前面,他们走了。这是一项艰巨的工作,但最终他们在 20 分钟内完成了。当她回到家时,她发现3在她的床上。她很伤心。