Mad Lib 生成器,字符串对齐

时间:2021-07-13 04:12:11

标签: string alignment madlib

嗨,我正在尝试创建 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))

我得到的输出是

圣诞惊喜的故事 莉莉在圣诞节那天醒来,​​发现她没有礼物! 在她的床尾,她发现了一封来自圣诞老人的两个小精灵的信。 它说圣诞老人很高兴。 看完信后,她发现自己被带到了公园。 在那里,她遇到了一个名叫约翰的精灵。他说他是圣诞老人的帮手。 因为圣诞老人很高兴,莉莉不得不在他们醒来之前将所有 37 份礼物分发给世界各地的每个人。 基拉在前面,他们走了。 这是一项艰苦的工作,但最终他们在 20 分钟内完成了。 当她回到家时,她在床上发现了 3 个。她好伤心。

0 个答案:

没有答案