# An error I get when trying to call a function I made

**URL:** https://forum.makecode.com/t/an-error-i-get-when-trying-to-call-a-function-i-made/27910
**Category:** Help
**Tags:** game
**Created:** [March 23, 2024, 12:18am UTC](https://forum.makecode.com/t/an-error-i-get-when-trying-to-call-a-function-i-made/27910 "2024-03-23T00:18:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Obsidian](https://avatars.discourse-cdn.com/v4/letter/o/51bf81/32.png) [@Obsidian](https://forum.makecode.com/u/Obsidian)
#### Post date: [March 23, 2024, 12:18am UTC](https://forum.makecode.com/t/an-error-i-get-when-trying-to-call-a-function-i-made/27910/1 "2024-03-23T00:18:58Z")

</div>

So basically I have this function compare\_arrays. For my assingment and almost as soon as it gets called make code arcade gives this error that I’m guessing is an internal error.  
“e.findIdx is not a function” no line number since it does not exist in my code. Here is my function:

```python
def compare_arrays(arr1, arr2):
    
    feedback = [0, 0, 0, 0] # Initialize feedback array with zeros
    for i in range(3):

        print(arr1)
        print(i)
        if arr1[i] == arr2[i]:
            print("set to 1")
            feedback[i] = 1
            print(arr1 + ", " + arr2 + ", " + feedback)
        elif isin(arr1[i], arr2):
            print("set to 2")
            feedback[i] = 2
            print(arr1 + ", " + arr2 + ", " + feedback)
        else:
            print("set to 0")
            feedback[i] = 0
            print(arr1 + ", " + arr2 + ", " + feedback)
    return [feedback[0],feedback[1],feedback[2],feedback[3]]

def isin(val, arr):
    for i in range(4):
        if arr[i] == val:
            return True
    
    return False

```

Here is the link to my project: [https://arcade.makecode.com/S04313-39937-09651-25135](https://arcade.makecode.com/S04313-39937-09651-25135)  
the controls are:  
left arrow: move selector left  
right arrow: move selector right  
up arrow: submit guess  
down arrow: select  
B Button: open the color picker menu

The project is based off of the game master mind. It would help anyone to understand this project and how it works if they understand how to play master mind.

---

<div class="post-metadata">

### Author: ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)
#### Post date: [March 23, 2024, 12:46am UTC](https://forum.makecode.com/t/an-error-i-get-when-trying-to-call-a-function-i-made/27910/2 "2024-03-23T00:46:16Z")

</div>

Welcome, @Obsidian !

This is a great looking game!

This is a tough error to track down! But I think I know how to help you.

Sometimes, Python gets confused as to a variable’s _type_, particularly with function parameters. If you run into this error, it’s likely that Python doesn’t know that your parameters are lists. Change your `compare_arrays()` function definition to this:

```python
def compare_arrays(arr1: List[number], arr2: List[number]):

```

This notation lets Python know the _type_ of these two parameters.

Also, to simplify your function, at the end, just `return feedback`. You don’t have to create a new array with the elements in `feedback`; just return the array as it is.

You’ll need to make a similar correction to `isin()`.

```python
def isin(val, arr: List[number]):

```

Once you do that, then Python should be happier with your code. At least, your project was running for me without generating any errors.

If you get stuck again, just let us know! Be sure to post a new share link with your new code.

Great project! And only after unit 2! Impressive!

---

<div class="post-metadata">

### Author: ![Obsidian](https://avatars.discourse-cdn.com/v4/letter/o/51bf81/32.png) [@Obsidian](https://forum.makecode.com/u/Obsidian)
#### Post date: [March 25, 2024, 6:33pm UTC](https://forum.makecode.com/t/an-error-i-get-when-trying-to-call-a-function-i-made/27910/3 "2024-03-25T18:33:51Z")

</div>

Oh wow! Thank you so much, this actually did fix it! I never knew that about python, so I guess I also learned something from this. If I do get stuck again I will definitely let you know thanks for the help! And Thank you!
