Help Needed Please! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help Needed Please!

What's wrong with this code 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()) #your code goes here adult=20 child=5 def revenue(x): counter=0 for value in data.values(): if value>18: counter+=adult else: counter+=child return revenue firstGrowth=revenue(18) finalGrowth=revenue(age) growthAnalysis= int(((finalGrowth - firstGrowth)/firstGrowth)*100) print(growthAnalysis )

11th Dec 2021, 3:35 PM
Ochola Mark Joshua
Ochola Mark Joshua - avatar
4 Answers
+ 1
may i ask you something ? what the use of *x* in revenue function ? i dont know any of it because im newbie. sorry for asking a question that not match with your question . . .
11th Dec 2021, 3:48 PM
キャサリン
キャサリン - avatar
+ 1
In your funtion, it should be: if value > x: You are now not using x in the function.
11th Dec 2021, 4:07 PM
Paul
Paul - avatar
+ 1
Paul Thank you I often call it an offside function error, You saved my day
11th Dec 2021, 4:13 PM
Ochola Mark Joshua
Ochola Mark Joshua - avatar
+ 1
キャサリン x is an empty variable waiting to be updated whenever we use that function
11th Dec 2021, 4:14 PM
Ochola Mark Joshua
Ochola Mark Joshua - avatar