Python list, set, dictionairy | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python list, set, dictionairy

Hello everyone, i have a little problem that i cant solve by my self. this is my code: https://code.sololearn.com/cVYBd627c06W/#py and this is the question asked : 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% So, for the input 14, your program should output 20. The output should be an integer (use int() to convert the result). but with my code im getting something wrong, with input "16" for example im getting the result right, but the same code is wrong with input "10". and i dont know how this even can be possible. thanks for your help!

17th Jan 2022, 7:16 PM
Ramiz Besic
Ramiz Besic - avatar
3 Answers
+ 5
"... the ticket for a child under 18 is $5". if age1 >= 18: if age2 >= age:
17th Jan 2022, 8:11 PM
Solo
Solo - avatar
+ 3
You are using too many variables. Calculate, reset the variables and re-calculate. Better yet, write a function to avoid repeating the same code twice.
17th Jan 2022, 9:59 PM
Solo
Solo - avatar
+ 1
Oh my god! Of course! Thanks so much!
17th Jan 2022, 8:25 PM
Ramiz Besic
Ramiz Besic - avatar