我试图让它在用户使用while循环和break函数输入客人姓名的地方,当循环结束时,我希望列表以编号顺序打印出来
詹姆士
卡尔
丽莎
布莱恩
但是可以输入多少个名字没有限制
我已经尝试过 while true 循环,但是当我使用
print("\nMy Wedding Attendees are: " "\n", extra)它只打印出我的婚礼参加者是:但不是名字
print("Now enter the names of other people you are inviting to your wedding\n")
counter = 1
extra = input("Guest's Name(or press Enter to quit): ")
while counter >= 1: #WHILE loop
extra = input("Guest's Name(or press Enter to quit): ")
counter = counter + 1
if extra == "":
break #break Statement
print("\nMy Wedding Attendees are: " "\n", extra)
我希望它看起来像
我的婚礼参加者是: 1. 姓名 2. 姓名 3. 姓名 4. 姓名
RISEBY
侃侃尔雅
红糖糍粑
慕斯王
随时随地看视频慕课网APP
相关分类