What's the issue in my code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the issue in my code?

What's the issue in my code? Only one test case is getting output and the rest are not 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": 4 } org = 0 for var in data.values() : if var<18: org += 5 else: org += 20 age = int(input("")) new_total = 0 for var in data.values(): if var<age: new_total += 5 else: new_total +=20 x = (new_total - org)/org * 100 print (int(x))

12th Apr 2021, 1:21 PM
Khushboo Golampalle
Khushboo Golampalle - avatar
6 Answers
+ 1
Khushboo, did you try my answer? If you do, it'll work for sure. The code you shared is perfect. You only lost a digit from your data variable's value.
13th Apr 2021, 12:10 AM
Josh Greig
Josh Greig - avatar
+ 1
You mistakenly removed a digit from your data. The last value should be 40. Not 4. "87-430": 40 Other than that, your code will work. I took your code and just made the above fix and all test cases passed so I'm absolutely sure it'll work for you too.
12th Apr 2021, 1:57 PM
Josh Greig
Josh Greig - avatar
0
You are analyzing sales data from a ticket office. The ticket for an adult is $20, while the ticket for a child under 18 is $5. The data you are given is in a dictionary format, where the keys are the sold ticket numbers, and the values are the customer ages. For example, "123-08": 24 means that the ticket was bought a 24 year old. Your goal is to calculate how much more money the office would make if it would change the ticket discount age to the given input. So, your program needs to take an integer as input and output the percentage of revenue growth, if the discount was given to people under that age. For example, if the office made $15000 with the original discount age, and would make $18000 with 14 as the discount age, then the growth would be ((18000-15000)/15000)*100 = 20%
12th Apr 2021, 3:07 PM
Khushboo Golampalle
Khushboo Golampalle - avatar
0
This is the description
12th Apr 2021, 3:07 PM
Khushboo Golampalle
Khushboo Golampalle - avatar
0
Worked 👍
13th Apr 2021, 3:46 AM
Khushboo Golampalle
Khushboo Golampalle - avatar
- 1
I think this Code is fine U can edit it with comments let's see what you are trying to achieve with each step
12th Apr 2021, 3:04 PM
Elusakin Oluwanifemi Joseph
Elusakin Oluwanifemi Joseph - avatar