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)
6 Antworten
+ 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)
+ 1
you need to uncomment the 'input' line inside the 'while' loop block ;)
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.
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)
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 !🔅
0
Prabuddh Bhatia don't put the string at input argument: this should make the test fail ;P