+ 1

Hit or miss EOF error

I'm trying to complete the hit or miss project in python for beginners but keep getting an EOF error. My research suggests it's not seeing any input. Can anyone point me in the right direction? Here is my code so far: #your code goes here x = 0 points = 100 while x < 5: score = input() if score == 'hit': points += 10 if score == 'miss': points -= 20

4th Jun 2021, 10:05 PM
John
7 ответов
+ 2
John My last post was not exact. My apologies for the confusion. When you hit RUN, the code will look for 5 inputs which will be supplied by Sololearn, but if you wish to test, then use the following format. Hit RUN # Now enter 5 options hit #enter hit # enter hit # enter miss # enter hit # Submit Each time you hit ENTER a new line will appear for you to place your next input. SUBMIT will then allow your code to process the inputs
5th Jun 2021, 11:23 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 4
Your updated code now works, except you haven't added print(poits) to output the result. In Sololearn, you must input all your inputs before hitting RUN. Your code allows 5 shots, so try: hit hit hit miss hit RUN
5th Jun 2021, 1:59 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
You aren't incrementing x inside while loop , so it keeps asking asking for input infinitely.
4th Jun 2021, 10:15 PM
Abhay
Abhay - avatar
+ 1
Well spotted I've updated the code but still getting the error. Here is the updated code: #your code goes here x = 0 points = 100 while x < 5: x += 1 score = input() if score == 'hit': points += 10 if score == 'miss': points -= 20
5th Jun 2021, 12:56 AM
John
+ 1
All good figured it out. I was looking for 5 inputs but there was only 4 so the EOF error was being produced on the 5th run through the loop. Thanks for your help
5th Jun 2021, 12:45 PM
John
0
How do I input all the inputs before running the code? I thought the input prompts at each run through of the program? I assumed Solo Learn would have written the project to see the input and then input a random selection of "hit" or "miss"
5th Jun 2021, 10:55 AM
John
0
Guys can you help me also score = 100 count= 0 shoot1= str(input()) shoot2= str(input()) shoot3= str(input()) shoot4= str(input()) while count <4: #First shoot if shoot1 == "hit": score+=10 elif shoot1 == "miss": score-=20 #Second shoot elif shoot2 == "hit": score+=10 elif shoot2 == "miss": score -= 20 #Third shoot elif shoot3 == "hit": score+=10 elif shoot3 == "miss": score -=20 #Forth shoot elif shoot4 == "hit": score +=10 elif shoot4 == "miss": score -=20 else: print("That\'s not a correct input") count +=1 print(score)
14th Jun 2021, 10:46 AM
Bryan Buenaver
Bryan Buenaver - avatar