2013-03-01 58 views
0

下面是一個代碼,我有一小塊:如何讓python添加一個字符串在一起?

studentName = "" 

def getExamPoints (total): 
    for i in range (4): 
     total = 0.0 
     examPoints = input ("Enter exam score for " + studentName + str(i+1) + ": ") 
total = ????? 
total = total/.50  
total = total * 100 

其中?????是我無法弄清楚如何獲得字符串來添加四個分數

學生的名字我輸入後來,它是需要在程序後面我使用examPoints = getExamPoints(studentName)

回答

1

沒有任何錯誤檢查錯誤的輸入:

total = 0.0 
for i in range (4): 
    total += int(input ("Enter exam score for " + studentName + str(i+1) + ": ")) 
total = total/.50  
total = total * 100 
1

你嘗試

total += int(examPoints); 
+0

工作完美!謝謝!!!!! – user2031682 2013-03-01 06:40:46

相關問題