Python3.6全棧開發執行個體[015]

來源:互聯網
上載者:User

標籤:程式   rate   else   開發   from   while   str   ice   美麗   

15.電影投票:程式先給出幾個目前正在上映的電影列表. 由使用者給每個電影投票.
最終將該使用者投票資訊公布出來 lst = [‘北京遇上西雅圖‘, ‘解救吳先生‘, ‘美國往事‘, ‘西西里的美麗傳說‘]
結果: {‘北京遇上西雅圖‘: 99, ‘解救吳先生‘: 80, ‘美國往事‘: 6, ‘西西里的美麗傳說‘: 23}

lst = [‘北京遇上西雅圖‘, ‘解救吳先生‘, ‘美國往事‘, ‘西西里的美麗傳說‘]new = []dic = dict.fromkeys(lst,0)  # {‘北京遇上西雅圖‘: 0, ‘解救吳先生‘: 0, ‘美國往事‘: 0, ‘西西里的美麗傳說‘: 0}while 1:    for i,j in enumerate(dic,1):        print(i,j)        new.append(j)    choice = input(‘請輸入序號或影片名字進行投票‘).strip()    if choice.isdigit():        choice = int(choice)        print(new[choice-1])        dic[new[choice-1]] += 1    elif choice in dic:        dic[choice] += 1    elif choice.upper() == ‘Q‘:        print(dic)        break    else:        print(‘你輸入的資訊有誤,請重新輸入!‘)    print(dic)

 

Python3.6全棧開發執行個體[015]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.