I want the if-statement to break if the condition is met, because currently if it isn't broken early then I get some mishaps in my code.
The problem is, I am not sure where to put the break. When I put it where it is shown here I get "Unexpected indent", but when I put it back a level I get an error with the else-statement saying "Invalid Syntax".
EDIT: THE IF IS INDENTED. It just didn't show up in the sites code blocks. I will try and fix it on the site.
@duck, what do you think I am trying to do? I am in my first weeks of a python course. I came here to help myself, not get my code trolled by you. If you can help me then I would appreciate the help, otherwise I don't need you telling to "learn how to code" when that's exactly what I am trying to do.
So I am not sure what to do. Any help would be appreciated.
def pTurn(CampLoc, AICampLoc, score, yourHits, cHits):
if yourHits < 5:
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"
def
should have an indent. – Rohit Sep 26 '13 at 5:01score = score
etc? – Blorgbeard Sep 26 '13 at 5:04