2013-03-01 61 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

相关问题