0
Pull the Trigger
Game where you output 'Hit' or 'Miss' with a total of 110 points My code: points = 100 action = 4 while action < 5: result = input() if result=="hit": points += 10 action -= 1 elif result == "miss": points -=20 action -=1 print (points)
5 ответов
+ 2
Kevin Calderon
You will get error because you are decrementing action after each iteration so loop will work till infinite because of condition action < 5.
Since there is only 4 iteration so you have to initialise action with 1 and after each iteration you should increment counter instead of decrement.
+ 1
1) your while condition is wrong, as you start action as 4 and decrease it by one at each iteration... however, to take 5 actions, rather initialize action to zero, and increase it by one at each iteration ^^
2) your if/elif blocks seems indented, but that's not clear: rather use more spaces to male the indentation clearer
3) I guess the print(points) must occurs only after 5 actions done... so without any indentation
4) if the game should end at 110 points, you must test it inside while loop and break if >= 110
+ 1
copy the full task description if you want to be helped further ;)
+ 1
Your action will always be less than 5 because you are only decrementing it...
See maybe you miss out some info in the question ❓
+ 1
Thanks, everyone. There are still some issues I have. But, I at least got it to run now.