HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to Python: Print and RepeatVariablesData Types & NumbersStringsListsConditions (if / elif / else)Loops (for / while)FunctionsOperatorsDictionariesTuples & SetsError Handling (try / except)Classes (Object-Oriented)File OperationsComments & IndentationBooleans (True / False)Lambda & map / filterModules (import)InheritanceVariable Scope
REFERENCE
📖 Overview
🖥️ Output & Input
🔢 Numbers & Math
✍️ String
📋 List
🗂️ Dictionary & Set
dictionary {}get()keys() / values() / items()set
🔁 Condition & Loop
🧩 Function
📁 File & Error
🔄 Type & Conversion
Python›REFERENCE›Dictionary & Set›dictionary {}

dictionary {}

Stores key-value pairs.

Syntax

name = {"key": value}

Description

A dictionary is created with curly braces. A value is accessed via its key (not an index). It's like 'labeled boxes' in the real world.

Returns

A dictionary object.

Example

Loading editor…

Expected output

Alex
{'name': 'Alex', 'age': 36, 'city': 'London'}

When to use?

Holding an object's attributes (a user, a product); JSON data.

Common mistakes

  • ⚠️ Accessing a missing key raises an error; use .get() for safe access.

Related commands

get()keys() / values() / items()
get() →
HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code