试试这个:def pTurn(CampLoc, AICampLoc, score, yourHits, cHits):
if yourHits < 5:
#^This line ident is probably the offending line. ;)
hGuess = int(raw_input("Enter a co-ordinate to air-strike: "))
print "Air-striking co-ordinate: %d" % hGuess
for cSpot in AICampLoc:
if hGuess == cSpot:
yConfirMsg = "Kill confirmed!!"
yourHits += 1
score += 100
AICampLoc.remove(hGuess)
break
else:
yConfirMsg= "No casualties"
score = score #You may want to fix this, since the logic doesn't make sense
yourHits = yourHits #Fix this line as well. This is variable value assignment to the same variable.
如果这不起作用,另一件要考虑的事情是,在缩进代码的前导空格时,可能会无意中混合使用制表符和空白。如果是,请将所有选项卡转换为空格。
关于引用的注释。也许你是想回报那些价值观?如果是的话,你需要修正那些逻辑错误。
更新:
如果只需断开一次和一次,则应将break替换为return。
如果没有,那么您应该捕获位置,继续循环执行,并对该信息执行任何操作。#...
values = {}
all_values = []
for cSpot in AICampLoc:
if hGuess == cSpot:
yConfirMsg = "Kill confirmed!!"
yourHits += 1
score += 100
AICampLoc.remove(hGuess)
values['message'] = yConfirMsg
values['hits'] = yourHits
values['score'] = score
values['camploc'] = AICampLoc
all_values.append(values)
else:
yConfirMsg= "No casualties"
#...