TypeError

The Python exception raised when an operation gets a value of the wrong kind, such as hashing a list.

In more detail

hash([1, 2]) raises "TypeError: unhashable type: 'list'", and so does using a list as a dict key or adding it to a set. The fix is usually to convert the list to a tuple. TypeError is also raised when comparing values that have no defined order, such as a number and a string during a sort.

Example

ip_network("::/0").subnet_of(ip_network("10.20.9.0/24"))   # raises TypeError

Related terms

Taught in

References

Certification courses