+ 1
Why an EOFError? (LINE 13)
8 odpowiedzi
+ 3
Lee SolidHeart The code is fine, you just need to enter everything at once in separate lines as soon as you run the program. So when you tab on 'Run', you need to enter something like:
1
80
# result: not enough money
or
1
590
# enough money etc.
+ 2
I dont know is it true or not but what i know is EOFError happened when your input doesnt have endline so your program cant read it (Maybe)
+ 2
Oh
Thanks for advice
+ 2
aha. 'Input in seperate lines' meant that. Again, thanks for your advice (s)! Problem solved.
+ 1
thanks
+ 1
The problem is that your code is wrapped in an infinite loop and there aren't break statements for all possible situations.
Situation 1: User enters 1 -> another input() -> user doesn't have enough money -> break -> loop stops
Situation 2: User enters 1 -> another input() -> user has enough money -> no break -> infinite loop, program expects more user input (this is where the EOFError happens)
Situation 3: User enters 2 -> break -> loop stops
Situation 4: User enters neither 1 nor 2 -> no break -> infinite loop, program expects more user input -> EOFError
It should work if you add another break after coffee -= 1 and in the very last line.
Please note that you have to enter all of your input in separate lines as soon as you run the program. So you have to enter something like this (without quotation marks):
"1
600"
+ 1
hmm
I changed.. and wow what's the problem?
https://code.sololearn.com/c2X7QN85vfOU/?ref=app