Python 为什么我的代码在cost_of_green=cost_of_green+;X*G
请帮助我查找代码中错误的原因cost\u of_green=cost\u of_green+X*GPython 为什么我的代码在cost_of_green=cost_of_green+;X*G,python,Python,请帮助我查找代码中错误的原因cost\u of_green=cost\u of_green+X*G T = int(input()) for i in range(0,T): cost_of_green = 0 cost_of_purple =0 G = int(input()) P = int(input()) n = int(input()) for j in range(0,n): X = int(input())
T = int(input())
for i in range(0,T):
cost_of_green = 0
cost_of_purple =0
G = int(input())
P = int(input())
n = int(input())
for j in range(0,n):
X = int(input())
Y = int(input()
cost_of_green =cost_of_green + X*G
cost_of_purple = cost_of_purple + Y*P
print(cost_of_green+cost_of_purple)
这只是一个简单的语法错误 。
)
行尾缺少。
这将导致编译器为下一行抛出错误。您缺少该行的结束括号
Y = int(input())
这会导致编译器下一行的上下文错误。在输入Y值的末尾缺少a)。
Y=int(输入())
在那之后它会起作用的 您在
Y=int(input()
)处缺少一个“')。您应该编写Y=int(input())
,以使代码正常工作。提示:语法错误通常是由编译器/解释器提到的位置以上的内容引起的。