25th Dec 2018, 8:11 AM
Lee SolidHeart
Lee SolidHeart - avatar
8 Answers
+ 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.
26th Dec 2018, 6:35 AM
Anna
Anna - avatar
+ 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)
25th Dec 2018, 8:22 AM
ShortCode
+ 2
Oh Thanks for advice
25th Dec 2018, 11:10 AM
Lee SolidHeart
Lee SolidHeart - avatar
+ 2
aha. 'Input in seperate lines' meant that. Again, thanks for your advice (s)! Problem solved.
26th Dec 2018, 7:33 AM
Lee SolidHeart
Lee SolidHeart - avatar
+ 1
thanks
25th Dec 2018, 8:45 AM
Lee SolidHeart
Lee SolidHeart - avatar
+ 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"
25th Dec 2018, 9:43 AM
Anna
Anna - avatar
+ 1
hmm I changed.. and wow what's the problem? https://code.sololearn.com/c2X7QN85vfOU/?ref=app
26th Dec 2018, 4:49 AM
Lee SolidHeart
Lee SolidHeart - avatar