+ 4

Hi, I'm have trouble with python beginner 24.2 test. Pls help.

total=0 x=0 while x<=5: a=int(input()) if a>3: total += 100 x+=1 print(total) After the system said there's an error in line 4

9th Mar 2022, 10:29 AM
Charles Ong
13 Answers
+ 1
total=0 x=0 while x<=5: # for six inputs a=int(input()) if a>3: total += 100 x+=1 print(total)
9th Mar 2022, 12:47 PM
Solo
Solo - avatar
+ 4
Always share code link by saving.. It should be identation error, And you started from 0 so x<5 works fine for 5 inputs.. Instead of x<=5 edit: Charles Ong if block is out side of while loop. add it into loop. currently it's infinite loop..
9th Mar 2022, 10:34 AM
Jayakrishna 🇮🇳
+ 3
Charles Ong , it looks like this is the task description. can you confirm that? it is *python for beginners* tutorial and *exercise 26.3* You are making a ticketing system. The price of a single ticket is $100. For children under 3 years old, the ticket is free. Your program needs to take the ages of 5 passengers as input and output the total price for their tickets. Sample Input ...
9th Mar 2022, 8:02 PM
Lothar
Lothar - avatar
+ 2
what error does it say? Also i can't really tell, but the indentation looks off. You may have an infinite loop
9th Mar 2022, 10:34 AM
Slick
Slick - avatar
+ 2
Thanks Solo, it seems it has an error just because of spacings
10th Mar 2022, 3:35 AM
Charles Ong
+ 2
E3 shubhanshu srivastava 47 , the condition in your suggested code is not correct: if age > 3: read the task description carefully to find the issue.
11th Mar 2022, 10:51 AM
Lothar
Lothar - avatar
+ 1
Jayakrishna🇮🇳 How do I share the link I'm using the app btw
9th Mar 2022, 11:55 PM
Charles Ong
+ 1
Slick The error says : File"/usercode/file0.pg",line 4, in <module> a=int(input()) EOFError: EOF when reading a line
10th Mar 2022, 3:30 AM
Charles Ong
+ 1
This may help you, to share links Charles Ong https://www.sololearn.com/post/75089/?ref=app You can find share option, you can copy by there also, and paste here. By the way, it's just space, but it's syntax rule of Indentation important in python.. Hope these may help you about indentation.. https://code.sololearn.com/cT5BRIbkia21/?ref=app https://www.sololearn.com/discuss/2983351/?ref=app https://www.sololearn.com/discuss/2534829/?ref=app hope these helps.
10th Mar 2022, 1:03 PM
Jayakrishna 🇮🇳
0
Lothar it's exercise 24.2, but tue question is correct
9th Mar 2022, 11:56 PM
Charles Ong
0
total = 0 cost = 0 while total < 5: age =int(input()) if age >3: cost+=100 total+=1 else: cost+=0 total+=1 print(cost) You can try this one..
10th Mar 2022, 6:28 PM
shubhanshu srivastava
0
How can I start building my website with python help me with the codes
11th Mar 2022, 5:15 AM
James Banda
James Banda - avatar
0
Here in the question clearly says that if age is greater than 3 then add 100$ cost otherwise its travel cost free
11th Mar 2022, 10:53 AM
shubhanshu srivastava