0

Python for Beginners 24.3

I can figure out how to get it to stop repeating the first input. Can anyone tell me what I am getting wrong here? shots = input() points = 100 i = 0 while i < 4: if shots == 'hit': points += 10 print(points) elif shots == 'miss': points -= 20 print(points) i += 1

9th Sep 2021, 5:21 PM
Matt Trujillo
Matt Trujillo - avatar
4 Antworten
+ 2
You have to take the input within the loop. Right now you're taking input only once
9th Sep 2021, 5:29 PM
Simon Sauter
Simon Sauter - avatar
+ 1
Hi Matt! Another thing is that you have to print the final points instead of printing each points for every iteration. For that, you can print it outside loop. Here it is your corrected code. points = 100 i = 0 while i < 4: shots = input() if shots == 'hit': points += 10 #print(points) elif shots == 'miss': points -= 20 #print(points) i += 1 print(points)
9th Sep 2021, 5:38 PM
Python Learner
Python Learner - avatar
+ 1
Thank you. That makes a lot of sense.
9th Sep 2021, 6:57 PM
Matt Trujillo
Matt Trujillo - avatar
0
Thank you
9th Sep 2021, 5:30 PM
Matt Trujillo
Matt Trujillo - avatar