+ 1

Python practice code not giving expected output

On one of the test cases it gave an example of: hit miss hit miss my output was 140 when it was suppose to be 80 can you look through this code and try to see where this problem occurs code: action = input() turn = 1 points = 100 while turn <= 4: if action == 'hit': points += 10 elif action == 'miss': points -= 20 turn += 1 print(points)

4th Dec 2021, 7:51 PM
Evan Bain
Evan Bain - avatar
1 Resposta
+ 3
You have 4 inputs in this challenge not one, and you need to loop trought all if tham and depending of value change points. Your output is 140 because it will loop 4 times and every time add 10, because first input is hit, you never check others
4th Dec 2021, 8:00 PM
PanicS
PanicS - avatar