我正在努力用Python构建一个超级简单的分数计数器,这是我自学的语言。柜台应该只到200而不是结束。 我陷入了第二个循环,我在第13行第二个条件“> 200”时得到了无效的语法错误。
我还没有完成代码,因为我正在测试每个块。 我可以获得有关我收到错误的原因的帮助吗?此外,我确信这是一个混乱的代码,但我刚刚学习功能和参数,以及条件,所以这是我所知道的。 整个代码如下:
global score #creating starting score
score = 0 # set to 0
global high_score # highest score attainable
high_score = 200 # set to 200
global new_score # name to get current score
new_score = score + int(input("score: ")) # how current score is reached
def total(): # function to find the complete score
while score(): # loop for score at zero to add points
if score is 0:
print(new_score) #asks user for first score
break
while score(): # loop to keep adding numbers
if new_score < 0 and > 200:
print("next score: ", + score)
break
答案 0 :(得分:0)
if new_score < 0 and new_score > 200:
顺便说一下,这种情况永远不会发生:)你应该重新考虑你的逻辑。