Vic*_*nit -4 python python-3.x
我在这段代码中得到了一个语法异常**+ b**== c**:我不知道问题是什么帮助我...
def getValue():
a, b,c =1,2,3;
while a:
while b:
while c:
if a + b + c == 1000 and a** + b** == c**:
print("A : {} B : {} C:{}".format( a, b, c))
return a*b*c;
else:
c += 1;
b += 1;
a+=1;
print("Answer : {}".format(getValue()))
Run Code Online (Sandbox Code Playgroud)
对于那些对我的问题不屑一顾的人我接受了我的错误,但是对我的帖子给出了否定信息让我觉得不要问这个问题.如果它与本网站上的任何主题无关,则可以提供否定.但是对于我所犯的错误,并要求帮助进行审查,即使你发现它很愚蠢,就像我在弄清楚错误之后你做的那样,你不应该给予否定,这会让人失去理智.
胡乱猜测:
if a + b + c == 1000 and a**2 + b**2 == c**2:
Run Code Online (Sandbox Code Playgroud)
请注意,循环遍历c在这里真的没用,你可以使用 c = 1000 - b - a
也使用for循环而不是while.你是用其他语言移植的吗?
def getValue():
for a in range(1, 1000):
for b in range(a, 1000):
c = 1000 - a - b
if a ** 2 + b ** 2 == c ** 2:
print("A : {} B : {} C:{}".format(a, b, c))
return a * b * c
Run Code Online (Sandbox Code Playgroud)