Pull the trigger game code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Pull the trigger game code

If i place input before while statement then i don't get any output but if i place it after while statement the i get eof error. I have placed # before input statement for this post only. p = 100 s = 0 #x = input () while s <= 3: #x = input() if x == "hit": p += 10 s + 1 elif x == "miss": p -= 20 s + 1 print (p)

4th Jun 2021, 8:36 PM
Prabuddh Bhatia
Prabuddh Bhatia - avatar
6 Answers
+ 1
You've got an endless loop. Debug: s += 1 p = 100 s = 0 #x = input() while s <= 3: #x = input() if x == "hit": p += 10 elif x == "miss": p -= 20 s += 1 print(p)
4th Jun 2021, 9:37 PM
Solo
Solo - avatar
+ 1
you need to uncomment the 'input' line inside the 'while' loop block ;)
5th Jun 2021, 5:51 AM
visph
visph - avatar
0
Hi...the code seems to work with your suggestion (although I couldn't get it exactly ) but output does not match the desired one. I need to add 10 points for every hit and subtract 20 for every miss.
5th Jun 2021, 5:39 AM
Prabuddh Bhatia
Prabuddh Bhatia - avatar
0
The comment sign is added for this post only. In my code I tried it both ways. Adding input before as well as after while statement (without comment sign)
5th Jun 2021, 6:21 AM
Prabuddh Bhatia
Prabuddh Bhatia - avatar
0
p = 100 s = 0 while s <= 3: x = input("Enter here :") if x == "hit": p += 10 elif x == "miss": p -= 20 s+=1 print(p) # as visph suggested you should uncomment the input inside while block... # read the answers carefully !🔅
5th Jun 2021, 6:41 AM
Ratnapal Shende
Ratnapal Shende - avatar
0
Prabuddh Bhatia don't put the string at input argument: this should make the test fail ;P
5th Jun 2021, 6:55 AM
visph
visph - avatar