0

I'm having difficulties with this assignment, could anyone help please

You are making a game! The player tries to shoot an object and can either hit or miss it. The player starts with 100 points, with a hit adding 10 points to the player’s score, and a miss deducting 20 points. Your program needs to take 4 action results as input ("hit" or "miss"), calculate and output the player’s remaining points. Sample Input hit hit miss hit Sample Output 110 Explanation: 3 hits add 30 points, one miss deducts 20, making the total points equal to 110. Use a while loop to take input during each iteration and calculate the points. x = 100 while True: a = input() if a == 'hit': print('hit') x +=20 if a == 'miss': print('miss') x -= 30

29th Dec 2021, 3:26 PM
Abror Beck
3 Respuestas
+ 4
Abror Beck There are only 4 inputs so don't do while True: It is responsible for this EOF Also you don't have to print miss or hit. You just have to print final point
29th Dec 2021, 3:29 PM
A͢J
A͢J - avatar
+ 3
You have to use a counter for the while loop. Example for 4 inputs: x = 100 n = 1 while n <= 4 : n += 1 a = input() ... ...
29th Dec 2021, 4:07 PM
Coding Cat
Coding Cat - avatar
0
I keep getting EOF error messages on line 4: Traceback (most recent call last): File "/usercode/file0.py", line 4, in <module> a = input() EOFError: EOF when reading a line
29th Dec 2021, 3:26 PM
Abror Beck