Skip to ContentMini Arrow Down Icon
  • Codecademy Logo
  • Codecademy Logo
.clear()
.copy()
.fromkeys()
.get()
.items()
.keys()
.pop()
.popitem()
.setdefault()
.update()
.values()
Back to Python
  1. Docs/
  2. Python/
  3. Dictionaries/
  4. .keys()

.keys()

Open IconEdit on GitHub

The .keys() method of a Python dictionary returns list of its keys. It takes no arguments.

Syntax

dictionary.keys()

Codebyte Example

The following example creates a dictionary then prints all of its keys:

Favicon Icon
Code
Output
Loading...

Contributors

  1. StevenSwiniarski's avatar'
    StevenSwiniarski
Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.
Open IconEdit on GitHub

Learn Python on Codecademy

Career path

Computer Science

Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
Checker Dense
Includes 6 Courses
Checker Dense
Certificate Icon
With Professional Certification
Checker Dense
Level Icon
Beginner Friendly
82 Lessons
Course

Learn Python 3

Learn the basics of Python 3, one of the most powerful, versatile, and in-demand programming languages today.
Checker Dense
Certificate Icon
With Certificate
Checker Dense
Level Icon
Beginner Friendly
14 Lessons
Open IconEdit on GitHub

Contributors

  1. StevenSwiniarski's avatar'
    StevenSwiniarski
    StevenSwiniarski's avatar'
    StevenSwiniarski272 contributions

Company

  • About
  • Careers
  • Affiliates
    • Twitter Icon
    • Facebook Icon
    • Instagram Icon
    • Youtube Icon

Resources

  • Articles
  • Blog
  • Cheatsheets
  • Code challenges
  • Docs
  • Projects
  • Videos
  • Workspaces

Support

  • Help Center

Resources

  • Articles
  • Blog
  • Cheatsheets
  • Code challenges
  • Docs
  • Projects
  • Videos
  • Workspaces

Support

  • Help Center

Plans

  • Paid memberships
  • For students
  • Business solutions

Community

  • Forums
  • Chapters
  • Events
  • Discord

Codecademy from Skillsoft

Codecademy from Skillsoft

Subjects

  • AI
  • Cloud Computing
  • Code Foundations
  • Computer Science
  • Cybersecurity
  • Data Analytics
  • Data Science
  • Data Visualization
  • Developer Tools
  • DevOps
  • Game Development
  • IT
  • Machine Learning
  • Math
  • Mobile Development
  • Web Design
  • Web Development

Languages

  • Bash
  • C
  • C++
  • C#
  • Go
  • HTML & CSS
  • Java
  • JavaScript
  • Kotlin
  • PHP
  • Python
  • R
  • Ruby
  • SQL
  • Swift

Career building

  • Career paths
  • Career services
  • Interview prep
  • Professional certification
  • —
  • Full Catalog
  • Beta Content
  • Roadmap

Mobile

  • Download on the App Store
  • Get it on Google Play

Mobile

  • Download on the App Store
  • Get it on Google Play
  • Privacy Policy
  • Cookie Policy
  • Do Not Sell My Personal Information
  • Terms
Made with ❤️in NYC © 2023 Codecademy