#coding=big5 # 計分表 # list 函式應用 # Michael Dawson - 1/30/03 scores = [] choice = None while choice != "0": print \ """ 計分表 0 - 結束 1 - 顯示分數 2 - 加入分數 3 - 刪除分數 4 - 排序 """ choice = raw_input("選擇: ") print # exit if choice == "0": print "再見" # 分數列表 elif choice == "1": print "分數表" for score in scores: print score # 加入分數 elif choice == "2": score = int(raw_input("得分: ")) scores.append(score) # 刪除分數 elif choice == "3": score = int(raw_input("刪除分數: ")) if score in scores: scores.remove(score) else: print score, "不在記錄中" # 排序 elif choice == "4": scores.sort() scores.reverse() # want the highest number first # 錯誤選擇 else: print "抱歉", choice, "不是正確的選擇" raw_input("\n\n按 enter 結束...")