我TypeError: unsupported operand type(s) for +=: 'builtin_function_or_method' and 'int'
在尝试运行此代码时收到此错误 ( )
total_exams = 0
for total_exams in range(1, 100001):
sum += total_exams
print(sum)
sum = 0
total_exams = 0
while count <= 100000:
sum += total_exams
total_exams += 1
print(sum)
sum = int("Please enter Exam grade, or press 999 to end: ")
while true:
if sum <= 100:
sum += total_exams
total_exams += 1
elif sum == "999":
print(sum / total_exams)
总之,我只需要运行程序直到输入 999,然后找到所有输入数字的平均值。至少有一点帮助会很好。
所以我已将我的代码编辑为(新)
totalExams = 0
total_sum = 0
for totalExams in range (1, 100001):
total_sum += totalExams
print(total_sum)
total_sum = 0
totalExams = 0
while totalExams <= 100000:
total_sum += totalExams
totalExams += 1
print(total_sum)
exam_sum = int("Please enter Exam grade, or press 999 to end: ")
while true:
if exam_sum <= 100:
exam_sum += totalExams
totalExams += 1
elif exam_sum == "999":
print(exam_sum / totalExams)
回溯(最近一次通话最后):
文件“C:/Python33/vfvfv.py”,第 14 行,在 Exam_sum = int("请输入考试成绩,或按 999 结束:") ValueError: invalid literal for int() with base 10: ' Please enter Exam评分,或按 999 结束:'