【发布时间】:2020-10-07 18:42:30
【问题描述】:
这是我的代码
days = 10
total = 0
for currentday in range(1, days +1):
> bugs = int(input("how many bugs were collected on day"+ str(currentday),": ")
> total += bugs
print("The total number of bugs caught by the end of all",days,"days was",total)
我在第 6 行或“total += bugs”所在的位置不断遇到语法错误。 我什至无法确定错误是什么,所以我需要帮助找出问题所在
【问题讨论】:
-
>是您代码的一部分吗?如果是这样,那就是你的问题 -
代码中的
>无济于事。 -
您没有关闭第 5 行中的输入括号,您还使用了
,而不是+。应该是bugs = int(input("how many bugs were collected on day"+ str(currentday) + ": ")) -
插入 > 是为了在此处标记块,并不是我实际代码的一部分。下次我会省略它们。
标签: python loops for-loop syntax