# C1M4 Exercise 4 Candy Help

**URL:** <https://community.deeplearning.ai/t/c1m4-exercise-4-candy-help/892746>\
**Category:** AI Python for Beginners\
**Tags:** week-module-4, coursera-platform\
**Created:** [June 9, 2026, 11:44pm UTC](https://community.deeplearning.ai/t/c1m4-exercise-4-candy-help/892746 "2026-06-09T23:44:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jennifer\_Kilpela](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@Jennifer\_Kilpela](https://community.deeplearning.ai/u/Jennifer_Kilpela)\
**Post date:** [June 9, 2026, 11:44pm UTC](https://community.deeplearning.ai/t/c1m4-exercise-4-candy-help/892746/1 "2026-06-09T23:44:20Z")

</div>

I’m struggling with exercise 4 and get\_top\_candies. For the mean I used stats. and the hint tells me I should be using a dot. But isn’t get\_top\_candies already defining the \>= function for average popularity? So how would I even use stats.?

**[mentor edit - code removed]**

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [June 10, 2026, 12:26am UTC](https://community.deeplearning.ai/t/c1m4-exercise-4-candy-help/892746/2 "2026-06-10T00:26:57Z")

</div>

Every time you open a notebook to work on it, you must run all of the cells starting from the top.

I notice the cell counter is fairly high at “[39]” ,so I recommend you use “Kernel → Restart and clear all data” and then use “Cell → Run All”.

---

<div class="post-metadata">

**Author:** ![bmiteva](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/bmiteva/32/128438_2.png) [@bmiteva](https://community.deeplearning.ai/u/bmiteva)\
**Post date:** [June 10, 2026, 6:25am UTC](https://community.deeplearning.ai/t/c1m4-exercise-4-candy-help/892746/3 "2026-06-10T06:25:51Z")

</div>

To add to what @TMosh said, you are on the right track, but both functions get\_top\_candies and display\_pretty\_table are imported from ex4\_helper\_functions. Since you have imported ex4\_helper\_functions using the “import file\_name” format, you then need to use it as file\_name.function\_name. I hope this helps.

Also, per the forum guidelines, please only share the error you are getting rather than your code. I have deleted the screenshot.
