如何让python一起添加一个字符串?

时间:2013-03-01 06:22:44

标签: python string range

这是我的一小部分代码:

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)

2 个答案:

答案 0 :(得分: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 :(得分:1)

你试过吗

total += int(examPoints);