+ 1
25.2 Python for Beginners âpull the triggerâ
Need some help with my code! 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.
4 Answers
+ 3
points = 100
tries = 4
while tries > 0:
result = (input())
if result == "hit":
points +=10
tries -=1 #bug
else: result == "miss" #bug
points -=20 #bug
tries -=1 #bug
print (points)
#đdebug
points = 100
tries = 4
while tries > 0:
result = input()
if result == "hit":
points +=10
elif result == "miss":
points -=20
tries -=1
print (points)
+ 2
Thank you!!
0
points = 100
tries = 4
while tries > 0:
result = (input())
if result == "hit":
points +=10
tries -=1
else: result == "miss"
points -=20
tries -=1
print (points)
0
Thanks you so much for helping, I was a bit confused.