+ 2

Why am I getting "EOF when reading a line" in my code

I was doing the ballpark coding challenge and my code works in the coding playground but it does not working in the challenge. I keep getting " line 20, item2 = input(), EOFf when reading a line". Code as follows: menu = ['Nachos, Pizza, Cheeseburger, Water, Coke'] total1 = 0 item1 = input() if item1 == 'Nachos': total1 += 6 elif item1 == 'Pizza': total1 += 6 elif item1 == 'Cheeseburger': total1 += 10 elif item1 == 'Water': total1 += 4 elif item1 == 'Coke': total1 += 5 else: total1 += 5 total2 = total1 item2 = input() if item2 == 'Nachos': total2 += 6 elif item2 == 'Pizza': total2 += 6 elif item2 == 'Cheeseburger': total2 += 10 elif item2 == 'Water': total2 += 4 elif item2 == 'Coke': total2 += 5 else: total2 += 5 total3 = total2 item3 = input() if item3 == 'Nachos': total3 += 6 elif item3 == 'Pizza': total3 += 6 elif item3 == 'Cheeseburger': total3 += 10 elif item3 == 'Water': total3 += 4 elif item3 == 'Coke': total3 += 5 else: total3 += 5 total4 = total3 item4 = input() if item4 == 'Nachos': total4 += 6 elif item4 == 'Pizza': total4 += 6 elif item4 == 'Cheeseburger': total4 += 10 elif item4 == 'Water': total4 += 4 elif item4 == 'Coke': total4 += 5 else: total4 += 5 total = total4 tax = total*0.07 print(tax)

23rd Mar 2021, 7:57 PM
Elaf
15 Respostas
+ 3
Elaf input is given at once line, so you need only to call input() once... then you must split it on spaces: inputs = input().split() # don't forgot parenthesis ^^ that way you get a list of 4 items, each could be accesible by square bracket index notation...
23rd Mar 2021, 8:26 PM
visph
visph - avatar
+ 6
visph is it really solution? I did not belive it. Ok that will be removed now. Thanks for this information.
23rd Mar 2021, 9:00 PM
JaScript
JaScript - avatar
+ 3
Your code works fine. Here on SL Playground will be needed input data for all requests at start. Total you have in this code 4 inputs, that means four lines for input data.
23rd Mar 2021, 8:00 PM
JaScript
JaScript - avatar
+ 3
Elaf Unfortunately I cannot remember me about this task. Could you save it please in a file on SL Playground and with the description and provide a link here?
23rd Mar 2021, 8:22 PM
JaScript
JaScript - avatar
+ 1
you should use loop to take inputs... to handle any number of them (the task should give you a way to know when to stop taking input: either a first input with the number of items, or a special value at end to stop inputs)
23rd Mar 2021, 8:07 PM
visph
visph - avatar
0
JaScript Yes i know the code works in the playgroud but the code does not work in the Ballpark challenge
23rd Mar 2021, 8:07 PM
Elaf
0
wich course? wich lesson? I cannot find the ballpark challenge ^^
23rd Mar 2021, 8:12 PM
visph
visph - avatar
0
visph its under community and code coach. its called Ballpark orders
23rd Mar 2021, 8:19 PM
Elaf
0
I only have access to (free) code coach inside courses... could you copy-paste the task description/requirements?
23rd Mar 2021, 8:21 PM
visph
visph - avatar
0
visph You and three friends go to a baseball game and you offer to go to the concession stand for everyone. They each order one thing, and you do as well. Nachos and Pizza both cost $6.00. A Cheeseburger meal costs $10. Water is $4.00 and Coke is $5.00. Tax is 7%. Task Determine the total cost of ordering four items from the concession stand. If one of your friendā€™s orders something that isn't on the menu, you will order a Coke for them instead. Input Format You are given a string of the four items that you've been asked to order that are separated by spaces. Output Format You will output a number of the total cost of the food and drinks. Sample Input 'Pizza Cheeseburger Water Popcorn' Sample Output 26.75
23rd Mar 2021, 8:22 PM
Elaf
0
May be its a pro challenge. But i guess, there only one line of input with items space separated. Accept and split into more..Elaf
23rd Mar 2021, 8:22 PM
Jayakrishna šŸ‡®šŸ‡³
0
JaScript ttps://code.sololearn.com/cT6mnAUoPqJm/?ref=app You and three friends go to a baseball game and you offer to go to the concession stand for everyone. They each order one thing, and you do as well. Nachos and Pizza both cost $6.00. A Cheeseburger meal costs $10. Water is $4.00 and Coke is $5.00. Tax is 7%. Task Determine the total cost of ordering four items from the concession stand. If one of your friendā€™s orders something that isn't on the menu, you will order a Coke for them instead. Input Format You are given a string of the four items that you've been asked to order that are separated by spaces. Output Format You will output a number of the total cost of the food and drinks. Sample Input 'Pizza Cheeseburger Water Popcorn' Sample Output 26.75
23rd Mar 2021, 8:25 PM
Elaf
0
visph I see, so then I can do a for loop and solve it then, correct?
23rd Mar 2021, 8:28 PM
Elaf
0
sure: that's a more shortest way ;)
23rd Mar 2021, 8:29 PM
visph
visph - avatar
0
JaScript why posting the solution? it may help to solve the task, but not help to learn (practice is essential) ^^ however, posting solutions of 'pro' code coach is against sololearn rules ;P
23rd Mar 2021, 8:56 PM
visph
visph - avatar