0

What is Wrong With This Code, Always Give Mistake, the exercise is called pull the trigger in the flow control section

x = str(input()) while contador != 0: i = 100 if x == "hit": i = i + 10 elif x == "miss": i = i - 20 else: print("please, introduce 'hit' or 'miss'") print(i) contador - 1

2nd Dec 2021, 4:08 PM
Alejandro Medrano
2 Réponses
+ 6
Alejandro Medrano , please do not use an output that is not demanded by the task description. all code coach exercises are tested by a program that passes values for the various test cases and that receives results from the code. this will work perfectly, as long as only the demanded inputs and / or outputs are used in our codes. so you should remove this line: print("please, introduce 'hit' or 'miss'")
2nd Dec 2021, 7:09 PM
Lothar
Lothar - avatar
+ 1
contador is not declared before the loop and it is never changed so the loop would run infinitely. You need to change it inside the loop
2nd Dec 2021, 4:13 PM
Lisa
Lisa - avatar