你可以這樣做:
def getWins():
week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
scores = {} # Perhaps you want to return a dictionary? If not, just set this to 0 and += score below. Also, remove sum()
for day in week:
score = int(raw_input("Enter the number of wins on {}: ".format(day)))
scores[day] = score
return sum(scores.values())
getWins()
"""
>>> getWins()
Enter the number of wins on Monday: 5
Enter the number of wins on Tuesday: 4
Enter the number of wins on Wednesday: 5
Enter the number of wins on Thursday: 1
Enter the number of wins on Friday: 3
Enter the number of wins on Saturday: 7
Enter the number of wins on Sunday: 9
34
"""
您也可以將輸入作爲列表並相應地解析它。 你到底在問什麼? –
你的問題不清楚。請詳細說明。 –
感謝您的回覆,對於未詳細說明的問題,我一直在尋找的是程序在每次用戶輸入後列出一週中的不同日期,以便用戶可以輸入一週中不同日期的數據 –