我目前收到一条"TypeError: unsupported operand type(s) for +: 'int' and 'str' "
消息。这是我的代码
def studentGrades(gradeList):
avgGrades = [ ]
for element in gradeList:
isinstance(element, int)
i = 0
for j in element:
i = i + j
average = (sum(element) / len(element))
avgGrades.append(average)
return avgGrades
答案 0 :(得分:0)
看起来您只需要将j转换为int即可,如下所示:
for j in element:
i = i + int(j)