第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

檢查我的 Python 代碼并建議我進行所需的編輯

檢查我的 Python 代碼并建議我進行所需的編輯

紅糖糍粑 2024-01-27 16:06:12
我剛剛開始學(xué)習Python。我正在嘗試學(xué)習制作一個程序,詢問用戶的姓名和他們想要訪問的地點。并在調(diào)查結(jié)束時顯示結(jié)果。但是,如果用戶選擇將調(diào)查傳遞給其他用戶,則顯示的投票結(jié)果僅包含回答這些問題的最后一個用戶的姓名和地點。我該怎么做才能使程序顯示所有參與投票的用戶的結(jié)果。(代碼是不言自明的)print("Hello world")qstn_1="What is your name?\t"qstn_2="Where would you like to GO for vacation?\t"polling_active=Truewhile polling_active: name=input(qstn_1) place=input(qstn_2) other=input("Would you like other person to answer these survey questions ?\t\n") polling_active=False if other=='yes':      polling_active=True else:    polling_active=False           print("\n\n\t\t\tPOLLING RESULTS\n")print("\n\n\t" + name.title() + " would like to go to " + place + " for a vacation!\n")
查看完整描述

2 回答

?
慕村9548890

TA貢獻1884條經(jīng)驗 獲得超4個贊

count = 0

names = []

places = []

while True:

    choice = input("Type N to take survey, type Y to pass it other user :")

    if choice == 'Y' and count==0:

        print("No one has taken this survey")

        break



    elif choice == 'N':

        name = input("What is your name :")

        place = input("Where would you like to visit :")

        names.append(name)

        places.append(place)

        count += 1    


    elif choice == 'Y':

        print("The last user was", names[-1], "and", names[-1], "wanted to visit", places[-1])

        break


print("\n\n\t\t POLLING RESULTS\n")

for name, place in zip(names, places):

    print(name, "wanted to visit", place,"\n")


查看完整回答
反對 回復(fù) 2024-01-27
?
慕哥6287543

TA貢獻1831條經(jīng)驗 獲得超10個贊

一些修復(fù):


添加了列表,最后需要解壓列表。

print("Hello world")

qstn_1="What is your name?\t"

qstn_2="Where would you like to GO for vacation?\t"

polling_active=True

name_lst = []

place_lst = []

while polling_active:

    name_lst.append(input(qstn_1))

    place_lst.append(input(qstn_2))

    other=input("Would you like other person to answer these survey questions ?\t\n")

    polling_active=False

    if other=='yes':

        polling_active=True


      

    

print("\n\n\t\t\tPOLLING RESULTS\n")

for i_name, i_place in zip(name_lst, place_lst):

    print("\n\n\t" + i_name.title() + " would like to go to " + i_place + " for a vacation!\n")



查看完整回答
反對 回復(fù) 2024-01-27
  • 2 回答
  • 0 關(guān)注
  • 205 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號