0 out of 464 challenges solved

Element Search in Array

Write a Python function `element_search` that takes two arguments:

1. `arr` (a list of elements)
2. `element` (an element to search for in the list)

The function should return a tuple:
- The first value is a boolean indicating whether the `element` is present in the list.
- The second value is the index of the `element` in the list, or `-1` if the `element` is not found.

#### Example Usage
```python [main.nopy]
print(element_search([1, 2, 3, 4, 5], 3))  # Output: (True, 2)
print(element_search([1, 2, 3, 4, 5], 6))  # Output: (False, -1)
```
def element_search(arr, element):
    """
    Search for an element in the list and return a tuple with a boolean and the index.

    Parameters:
    arr (list): The list to search in.
    element (any): The element to search for.

    Returns:
    tuple: (bool, int) where bool indicates presence and int is the index or -1.
    """
    # Your code here
    pass