human
array get element by index with default.
assistant
Here is a Python function to array get element by index with default

import numpy as np

def get_element(array, index, default=None):
    """Returns the element at the given index in the array, or the default value if the index is out of range."""
    if index < 0 or index >= len(array):
        return default
    return array[index]

# Enter the array
array = np.arange(10)

# Calling the function
print((get_element(array, 2)))

#Example Output
# 2

#Remember to inspect code for bugs.