+ 1
Code fail
What is wrong with my code score=100 shots=4 while shots>0: result=input() if result=="hit" : score +=10 shots-=1 elif result=="miss" : score -=20 shots -=1 print(score)
6 Respuestas
+ 5
You need to fix your indentation so everything inside the while loop but that last line is indented a whole block
+ 3
John Delvin most likely wrong. Does OP want to print the score only when they miss?
0
Slick , here is the correction
score=100
shots=4
while shots>0:
result=input()
if result=="hit" :
score +=10
shots-=1
elif result=="miss" :
score -=20
shots -=1
print(score)
0
John Delvin that assumes that they want to print the score after every shot. I don't think that's the case. So the print statement should probably be placed outside of the loop.
0
Simon Sauter for me i love to see some out when i do something.
In games when you kill or shoot someone , some progress is shown and it still appears for as long as the game runs.I thought that was what the owner of this post wanted
- 6
This is the indented version
score=100
shots=4
while shots>0:
result=input()
if result=="hit" :
score +=10
shots-=1
elif result=="miss" :
score -=20
shots -=1
print(score)