ValueError: setting an array element with a sequence

import numpy as np

# Creating a 2D array
arr = np.array([[1, 2], [3, 4]])

# Try to set an element with a sequence
try:
    arr[0][0] = [5, 6]
except ValueError as e:
    print(e)

Watch a course Python - The Practical Guide

This code creates a 2D numpy array, and then tries to set the first element of the array to a list. However, numpy arrays must contain elements of the same data type, so this operation raises a ValueError with the message "setting an array element with a sequence."