+ 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

7th Jun 2021, 6:42 PM
Расим Багиров
Расим Багиров - avatar
5 odpowiedzi
+ 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)
7th Jun 2021, 7:07 PM
A͢J
A͢J - avatar
+ 2
Расим Багиров , because the continue statement should be indented to elif.
7th Jun 2021, 6:48 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 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
7th Jun 2021, 7:13 PM
Расим Багиров
Расим Багиров - avatar
+ 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
7th Jun 2021, 6:59 PM
A͢J
A͢J - avatar
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)
7th Jun 2021, 7:15 PM
A͢J
A͢J - avatar