- 1
Has anyone stumbled across this problem?
You are making a game! The player tries to shoot an object and can 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. https://code.sololearn.com/chiE8N12MEOZ/?ref=app https://code.sololearn.com/chiE8N12MEOZ/?ref=app https://code.sololearn.com/W9Z40v60i9iR/?ref=app
2 Respuestas
- 1
Python:
I =0
H = 100
while True:
if I>=4:
break
x=input()
if x == "hit":
H +=10
elif x == "miss":
H-=20
I+=1
print(H)
- 1
it worked! thanks :)