# Issue with "Candy Analysis"

**URL:** <https://community.deeplearning.ai/t/issue-with-candy-analysis/894402>\
**Category:** AI Python for Beginners\
**Tags:** week-module-5, dl-ai-learning-platform\
**Created:** [August 4, 2026, 7:42pm UTC](https://community.deeplearning.ai/t/issue-with-candy-analysis/894402 "2026-08-04T19:42:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonas\_Fritzin](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@Jonas\_Fritzin](https://community.deeplearning.ai/u/Jonas_Fritzin)\
**Post date:** [August 4, 2026, 7:42pm UTC](https://community.deeplearning.ai/t/issue-with-candy-analysis/894402/1 "2026-08-04T19:42:54Z")

</div>

\*\*Hi, In the “Candy Analysis”, \*\*

\*\*I initially code run the code properly down to the section below. How when stepping the code from the beginning, I always get the same error. \*\*

**NameError Traceback (most recent call last) Cell In[16], line 5 1**

\*\* ### START CODE HERE ### \*\*  
\*\*2 \*\*  
\*\*3 \*\*  
\*\*# Access the “get\_top\_candies” function in “ex4\_helper\_functions” \*\*  
\*\*4 \*\*  
\*\*# Pass “candy\_data” and “avg\_popularity” to the “get\_top\_candies” function ----\> \*\*  
\*\*5 top\_candies = get\_top\_candies(candy\_data, avg\_popularity) \*\*  
\*\*7 \*\*  
\*\*### END CODE HERE ### \*\*  
\*\*8 \*\*  
\*\*9 \*\*  
\*\*### Display the “top\_candies” list 10 ex4\_helper\_functions.display\_pretty\_table(top\_candies) \*\*  
**NameError: name ‘get\_top\_candies’ is not defined**

---

<div class="post-metadata">

**Author:** ![Kic](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/kic/32/76339_2.png) [@Kic](https://community.deeplearning.ai/u/Kic)\
**Post date:** [August 4, 2026, 10:53pm UTC](https://community.deeplearning.ai/t/issue-with-candy-analysis/894402/2 "2026-08-04T22:53:52Z")

</div>

Hi @Jonas_Fritzin ,

When calling the function get\_top\_candies(), it should be prefixed with where that function is located, in this case, it is ex4\_helper\_functions, follows by a dot. An example is given in displaying the to\_candies list of 10.

---

<div class="post-metadata">

**Author:** ![Jonas\_Fritzin](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@Jonas\_Fritzin](https://community.deeplearning.ai/u/Jonas_Fritzin)\
**Post date:** [August 5, 2026, 6:00pm UTC](https://community.deeplearning.ai/t/issue-with-candy-analysis/894402/3 "2026-08-05T18:00:49Z")

</div>

Thanks @Kic - now it works! 🙂

---

<div class="post-metadata">

**Author:** ![Mubsi](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/mubsi/32/94983_2.png) [@Mubsi](https://community.deeplearning.ai/u/Mubsi)\
**Post date:** [August 6, 2026, 9:36am UTC](https://community.deeplearning.ai/t/issue-with-candy-analysis/894402/4 "2026-08-06T09:36:11Z")

</div>

Closed on August 6, 2026, 9:36am UTC


