Index Ai Academy
Glossary · Phase 0 · Tools

Hashable

Also written: unhashable

A value that can't change, such as a number, string or tuple, so it can go in a set or be a dictionary key.

The price of that speed is a rule about what a set can hold: only hashable items, ones that can't change. Numbers, strings and tuples are fine. A list isn't, because changing it would change its hash and lose it inside the set. {[1, 2]} raises TypeError: unhashable type: 'list'; use a tuple, {(1, 2)}, instead.

Try it now

The right collection usually follows from one question: do you need order, names, or uniqueness?

Learn it properly

Sets: unique items and fast lookups · Duplicates, fast membership, set operations and comparing two lists. About 30 minutes.

Start this free lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write