在这里的某个地方。附:这是一场板球比赛。代码中没有任何地方突出显示。我能做什么?在此先感谢您的回答。我需要这个作业。它是有效的,直到我编辑了显示玩家得分的区域。我打算补充说有多少个小门掉了下来,但是在这个时间框架里,我搞砸了。感谢
playruns = playtemp
playscore = playscore + playruns
print("You scored" ,playruns, "runs.", team, "is on", playscore," runs.")
elif playruns == 5:
print("Your player is out! ", team,"'s current score is:", playscore,"runs")
playouts = playouts + 1
if playouts == 5:
print("You are all out. Now it is your turn to bowl.")
while compouts != 5:
print("The Androidz scored", compruns,"runs. The total score of the Androidz is", compscore,"runs.")
compruns = 0
comptemp = 0
compouts = compouts + 1
if compouts == 5:
print("Game over man, game over.")
print("Your score was:", playscore,)
print("The Androidz score was:", compscore.)
if playscore > compscore:
playagain = input("You are the winner.
print("The Androidz scored", compruns,"runs. The total score of the Androidz is", compscore.)
compruns = 0
comptemp = 0
compouts = compouts + 1
if compouts == 5:
print("The Androidz are all out. Congratulations.")
while playouts != 5:
print("You are now batting.")
playmindset = input("For this ball would you like to play agressively 'a', or defensively 'd'")
if playmindset == "a":
playtemp = random.choice([1,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,])
elif playmindset == "d":
playtemp = random.choice([1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,5,5,5,])
playruns = playtemp
playscore = playscore + playruns
if playruns != 5:
print("You scored" ,playruns, "runs.", team, "is on", playscore,"runs")
elif playruns == 5:
print("Your player is out! ", team,"'s current score is:", playscore.)
playouts = playouts + 1
if playouts == 5:
print("Game over man, game over.")
print("Your score was:", playscore,)
print("The Androidz score was:", compscore,)
if playscore > compscore:
playagain = input("You are the winner. Play againg?. 'y' for yes, 'n' for no.")
elif playscore < compscore:
playagain = input("You are the loser. Play againg?. 'y' for yes, 'n' for no.")
elif coinguess != headsortails:
while compouts != 5:
print("You lost the toss. You are bowling.")
print("The Androidz are at the crease. The hot sun beams down upon the ground.\nVictory is a must for", team, "if" , captainname, "wishes to remain as captain.")
bowltodo = input("Would you like to bowl or forfeit?")
comptemp = random.choice([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,])
if bowltodo == "bowl":
compruns = comptemp
compscore = compruns + compscore
print("The Androidz scored", compruns,"runs. The total score of the Androidz is",compscore,"runs.")
compruns = 0
comptemp = 0
compouts = compouts + 1
if compouts == 5:
print("The Androidz are all out. Congratulations.")
while playouts != 5:
print("You are now batting.")
playmindset = input("For this ball would you like to play agressively 'a', or defensively 'd'")
if playmindset == "a":
playtemp = random.choice([1,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,6,6,6,])
elif playmindset == "d":
playtemp = random.choice([1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,5,5,])
playruns = playtemp
playscore = playscore + playruns
if playruns != 5:
print("You scored" ,playruns, "runs.", team, "is on", playscore.)
elif playruns == 5:
print("Your player is out! ", team,"'s current score is:", playscore.)
playouts = playouts + 1
if playouts == 5:
print("Game over man, game over.")
print("Your score was:", playscore,)
print("The Androidz score was:",compscore,)
if playscore > compscore:
playagain = input("You are the winner. Play againg?. 'y' for yes, 'n' for no.")
elif playscore < compscore:
playagain = input("You are the loser. Play againg?. 'y' for yes, 'n' for no.")
答案 0 :(得分:4)
您有几个语法错误。第一个是第33行
elif playmindset == "d":
playtemp = random.choice([1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,5,5,])
playruns = playtemp
playscore = playscore + playruns
print("You scored" ,playruns, "runs.", team, "is on", playscore," runs.")
elif playruns == 5: # this line
print("Your player is out! ", team,"'s current score is:", playscore,"runs")
playouts = playouts + 1
第二个elif
会引发语法错误,因为它之前没有if
。也许你的意思是在第一个elif
中放置3行,或者让第二个elif
成为新的if
。那是你要修理的。
引发更多语法错误,因为您在程序中的多个位置打印这样的内容(第52,66,84,120,122行)
print("The Androidz score was:", compscore.)
.
后面的compscore
暗示你要调用它上面的函数,或者属性或其他东西。因为您不这样做会引发语法错误。我想你只想在行尾打印一个点,在这种情况下只需将它们改为
print("The Androidz score was:", compscore + ".")