+ 1
Something wrong , please help. Line 11 not in loop, why? How get correct ?
total = 0 ticket = 100 x = 1 x += 1 while x < 6: age = int(input()) if age > 3: a = ticket * 1 total += a elif age < 3: continue
5 Respostas
+ 2
Расим Багиров
Btw no need to write elif condition if you have condition age > 3 and also you are increasing x by 1 before executing while loop which is wrong. That should be inside loop.
Here is exact solution:
---------
total = 0
ticket = 100
i = 1
while i < 6:
age = int(input())
if age > 3:
total += ticket * 1
i = i + 1
print(total)
+ 2
Расим Багиров , because the continue statement should be indented to elif.
+ 2
Huh, I think I'm stupid, because ,every time when i find solutions for each exercise , i have wrong thinking
And every time im going to comments find right solution
+ 1
Расим Багиров
Because if, elif and continue are not properly indented. All should be inside loop.
total = 0
ticket = 100
x = 1
x += 1
while x < 6:
age = int(input())
if age > 3:
a = ticket * 1
total += a
elif age < 3:
continue
0
Расим Багиров
No problem it happens.
Btw if you want to use continue then you can also solve problem like this:
ticket = 100
total = 0
i = 1
while i < 6:
age = int(input())
i = i + 1
if age < 3:
continue
total += ticket * 1
print(total)