0

PULL THE TRIGGER . . . WHILE LOOP - PYTHON FOR BEGINNERS

I completely understand this concept, but this one really got me. We are only suppose to get one output of the total, but I keep getting 4 outputs . . .SOS ='( My code below: points=100 x=1 while x<5: my_input=input() if my_input=="hit": points +=10 elif my_input=="miss": points -=20 x=x+1 print(points) !!!!!!!!!!!!!!!MY CORRECT CODE IS IN THE ANSWER SECTION BELOW!!!!!!!!!!!!!!

27th May 2021, 10:52 PM
truqoddess
truqoddess - avatar
3 Respuestas
+ 8
because your last 'print' is inside the 'while' loop: try to unindent it, and tell us if your code still have problem to pass the tests ;)
27th May 2021, 11:01 PM
visph
visph - avatar
+ 6
OMFG - I've been wrecking my brain and pulling my hair out for two days straight trying to figure WTF I WAS DOING WRONG 😭 THANK YOU SO MUCH !!!!!!! Correct code with the help of @visph points=100 x=1 while x<5: my_input=input() if my_input=="hit": points +=10 elif my_input=="miss": points -=20 x=x+1 print(points)
27th May 2021, 11:07 PM
truqoddess
truqoddess - avatar
0
could you explain to help me better understand your code?
14th Jul 2021, 3:19 AM
John Liter
John Liter - avatar