num_1 = 3
num_2 = 5
num_3 = 15
div_1 = 1000/3
div_2 = 1000/5
div_3 = 1000/15
sum_1 = 0
sum_2 = 0
sum_3 = 0
i = 0
while (i<300):
sum_1 = sum_1 + i*3,
i = i + 1
print (sum_1)
i = 0
while (i<div_2):
sum_2 = sum_2 + i*5,
i += 1
i = 0
while (i<div_1):
sum_3 = sum_3 + i*5,
i += 1
print (sum_1)
输出:
(0,)
Traceback (most recent call last):
File "C:/Users/xxxxx/Documents/Python/1-p.py", line 12, in <module
sum_1 = sum_1 + i*3,
TypeError: can only concatenate tuple (not "int") to tuple
我是 Python 的初学者,我正在尝试编写一个简单的代码。
我不确定出了什么问题。谁能帮帮我。对此,我真的非常感激。