0
Struggling with a python code challenge
Iâm working on the âpull the triggerâ challenge and I keep getting an EOF error and it looks like itâs my input line that is causing issues. However, when I load my code in the playground I get the expected output (along with the error). Anyone have any ideas as to why this would be an issue? score = 100 attempt = 1 while attempt <= 4: print("what was the result") result = input() if result == "hit": score += 10 print(score) elif result == "miss": score -= 20 print(score) attempt += 1
7 RĂ©ponses
+ 1
Your code has two issues:
1. In the if block you need to add
attempt += 1
2. If I remember correctly the task requires only the final score ad output. So the print statement should be outside the loop.
+ 1
EOF error is because sololearn accepts all inputs in the first prompt (each input in a line) and then prints the output,
Try run this code in another IDE, and I think it will work properly
+ 1
Thanks for the help!!!
0
Yeah if seems to work in the playground. Trying to figure out how to satisfy sololearnâs requirements so i can pass the challenge. But itâs good to know that itâs not flat out bad code đ
0
Ah the final score. That makes sense. The examples they gave had the var += 1 statement at the very end so thsts what i did đ€·ââïž
0
You can do it with a single use of
attempt += 1
if you unindent it so it is executed independently of whether the if or the elif block is executed.
0
Nvm i see what you mean