Question: I want the item to be replaced with an another item when the overridden function fires.

```java
    @Override
    public ActionResultType itemInteractionForEntity(ItemStack stack, PlayerEntity playerIn, LivingEntity target, Hand hand) {

        if (!playerIn.world.isRemote()) {
            // Replace an item with xyz
        }

        return super.itemInteractionForEntity(stack, playerIn, target, hand);
    }

```

How can I achieve this?

Note: I'm using MCP mappings.

Answer: 
* Have you called the function yet?
* Don't use `list` as a name of the variable
* Update the function to return `True` only when all elements have a perfect square.

code:

```
num_list = [4, 9, 16]

def check_is_quadratic(x):
    result = []
    for i in x:
       if math.sqrt(i).is_integer():
           result.append(True)
       else: 
           result.append(False)
    return all(result)

print(check_is_quadratic(num_list))

```

output:

> 
> 
> ```
> > print(check_is_quadratic([4, 9, 16]))
> True
> > print(check_is_quadratic([4, 8, 16]))
> False
> 
> ```
> 
> 

---

UPDATE

code with list comprehension:

```
num_list = [4, 8, 16]
result = [math.sqrt(num).is_integer() for num in num_list]
print(result)
print(all(result))

```

output:

```
> [True, False, True]
> False

```
You are:

1. Not calling your function or printing anything
2. Using the global variable `list` inside your fucntion instead of the passed value
3. Using the reserved word `list` as a variable name, which is bad practice
4. Using return statement inside the if-else block here will give you only True/False once. What you want is to return True/False for each element inside your `testList`

An updated code could look like this:

```
import math

test_list = [4, 10, 16]

def check_is_quadratic(list_in_function):

    for i in list_in_function:
       if not math.sqrt(i).is_integer(): 
           return False # If one is not perfect square, then we can say False
    return True # Only after the complete for-loop we can say that all values are perfect squares

print(check_is_quadratic(test_list))

```