# C2W1 - #UNQ\_C4 Incorrect loop used in \`add\_interactions\` function

**URL:** <https://community.deeplearning.ai/t/c2w1-unq-c4-incorrect-loop-used-in-add-interactions-function/737140>\
**Category:** AI for Medical Prognosis\
**Tags:** week-module-1\
**Created:** [December 18, 2024, 1:22pm UTC](https://community.deeplearning.ai/t/c2w1-unq-c4-incorrect-loop-used-in-add-interactions-function/737140 "2024-12-18T13:22:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jialeichen](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@jialeichen](https://community.deeplearning.ai/u/jialeichen)\
**Post date:** [December 18, 2024, 1:22pm UTC](https://community.deeplearning.ai/t/c2w1-unq-c4-incorrect-loop-used-in-add-interactions-function/737140/1 "2024-12-18T13:22:53Z")

</div>

Functions are all correct and all tests are passed, still keep getting this error.  
Need help!  
Thanks!  
Lab Id: xafbjnhezepp

---

<div class="post-metadata">

**Author:** ![Girijesh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/girijesh/32/37283_2.png) [@Girijesh](https://community.deeplearning.ai/u/Girijesh)\
**Post date:** [December 18, 2024, 7:29pm UTC](https://community.deeplearning.ai/t/c2w1-unq-c4-incorrect-loop-used-in-add-interactions-function/737140/2 "2024-12-18T19:29:26Z")

</div>

Dear @jialeichen,

Which errors are you getting. Please describe.

---

<div class="post-metadata">

**Author:** ![jialeichen](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@jialeichen](https://community.deeplearning.ai/u/jialeichen)\
**Post date:** [December 19, 2024, 2:05am UTC](https://community.deeplearning.ai/t/c2w1-unq-c4-incorrect-loop-used-in-add-interactions-function/737140/3 "2024-12-19T02:05:23Z")

</div>

Hi @Girijesh,  
Thanks for your response!

I got the following error:  
Incorrect loop used in `add_interactions` function

 ![image](https://global.discourse-cdn.com/dlai/original/3X/6/c/6c1f571a8a8f3a407223981f86323edc11d4e156.png)

I double checked my loop body, and I am indeed using m in the loop instead of re-calculating.

Thanks!

---

<div class="post-metadata">

**Author:** ![jialeichen](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@jialeichen](https://community.deeplearning.ai/u/jialeichen)\
**Post date:** [December 19, 2024, 6:04am UTC](https://community.deeplearning.ai/t/c2w1-unq-c4-incorrect-loop-used-in-add-interactions-function/737140/5 "2024-12-19T06:04:25Z")

</div>

@Girijesh I’m not sure I understand what you are saying…  
I suppose this add\_interactions function is just calculating the product between every feature columns right?

 ![image](https://global.discourse-cdn.com/dlai/original/3X/2/0/201d9321bfce11f8146d9dd1bce788895c3ffa2c.png)

Do you mind if I message you my code?

Thanks!

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [December 19, 2024, 6:34am UTC](https://community.deeplearning.ai/t/c2w1-unq-c4-incorrect-loop-used-in-add-interactions-function/737140/6 "2024-12-19T06:34:34Z")

</div>

for the code line, make sure you used the right column 👇🏻

choose the index of column ‘j’ to be greater than column i, (i+1, m)

Anyways, probably the mentor you are asking should be able to help you out as you are seeking help from him.

Another issue last time learner had when they edited out naming and getting feature data in one step and use the same combination in the feature i\_j interaction.

Good luck

---

<div class="post-metadata">

**Author:** ![jialeichen](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@jialeichen](https://community.deeplearning.ai/u/jialeichen)\
**Post date:** [December 19, 2024, 7:03am UTC](https://community.deeplearning.ai/t/c2w1-unq-c4-incorrect-loop-used-in-add-interactions-function/737140/7 "2024-12-19T07:03:43Z")

</div>

@Deepti_Prasad  
You are right, I mistakenly used (i, m) for the range of column j instead of (i+1, m). Now the lab has passed 😃  
Thank you!
