0

Ticket Office from python data structures

I don't understand why my code doesn't work for the Ticket office project. Can someone explain the flaw in my logic? Thanks :) 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 } age = int(input()) old = 0 new = 0 for x in data.values(): if x > 18: old += 20 else: old += 5 for var in data.values(): if var > age: new += 20 else: new += 5 print(int((new - old) / old * 100))

7th Jan 2022, 4:57 PM
Allan Chuang
2 Answers
+ 1
Everything works good. Just I'd write like: age = int(input("enter the age: "))
7th Jan 2022, 5:48 PM
Shadoff
Shadoff - avatar
0
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 } age = int(input()) main = 0 new = 0 for original in data.values(): if original >= 18: main += 20 else: main += 5 main_total = main for change in data.values(): if change >= age: new += 20 else: new += 5 new_total = new Growth = (new_total - main_total) / main_total * 100 print(int(Growth))
19th Nov 2022, 12:37 AM
Mohamed Gomaa Soliman