Problem wiith Ticket Office Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Problem wiith Ticket Office Python

Help, please. What's wrong with my code? Maybe problem whith round the numbers? data = { "100-90": 25, "42-01": 48, "55-09": 12, "128-64": 71, "002-22": 18, "321-54": 19, "097-32": 33, "065-135": 64, "99-043": 80, "111-99": 11, "123-019": 5, "109-890": 72, "132-123": 27, "32-908": 27, "008-09": 25, "055-967": 35, "897-99": 44, "890-98": 56, "344-32": 65, "43-955": 59, "001-233": 9, "089-111": 15, "090-090": 17, "56-777": 23, "44-909": 27, "13-111": 21, "87-432": 15, "87-433": 14, "87-434": 23, "87-435": 11, "87-436": 12, "87-437": 16, "94-121": 15, "94-122": 35, "80-089": 10, "87-456": 8, "87-430": 40 } data1 = data.values() age = int(input()) tick_adult = 20 tick_ch = 5 price_new = 0 price_old = 515 count = 0 for value in data1: if value <= age: count += 1 price_new = tick_ch*count + tick_adult*(len(data1)-count) growth = int(((price_new - price_old)/price_old)*100) print(int(growth))

25th Mar 2021, 11:37 AM
Tatyana Kas
Tatyana Kas - avatar
3 Answers
0
Hi Tatyana, I think the only problem was that you might have misunderstood the question. The old price should be 530 if I'm not incorrect. And they're asking what the price would be for people under the age something. So your "if value <= age:" should be "if value < age:". Hope this helps :)
25th Mar 2021, 12:55 PM
Alexander Crum
Alexander Crum - avatar
0
A way to make the program get the old price is to use a for loop with if statements which can help eliminate our own mistakes
25th Mar 2021, 12:57 PM
Alexander Crum
Alexander Crum - avatar
0
Thanks! it's working)
26th Mar 2021, 10:40 AM
Tatyana Kas
Tatyana Kas - avatar