+ 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
13 Réponses
+ 1
total=0
x=0
while x<=5: # for six inputs
a=int(input())
if a>3:
total += 100
x+=1
print(total)
+ 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..
+ 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
...
+ 2
what error does it say? Also i can't really tell, but the indentation looks off. You may have an infinite loop
+ 2
Thanks Solo, it seems it has an error just because of spacings
+ 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.
+ 1
Jayakrishna🇮🇳
How do I share the link I'm using the app btw
+ 1
Slick
The error says :
File"/usercode/file0.pg",line 4, in <module>
a=int(input())
EOFError: EOF when reading a line
+ 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.
0
Lothar
it's exercise 24.2, but tue question is correct
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..
0
How can I start building my website with python help me with the codes
0
Here in the question clearly says that if age is greater than 3 then add 100$ cost otherwise its travel cost free