PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Python · Theory

dict.values()

← All stacks

Theory

257/268

dict.values()

dict.values() works on a dictionary — labelled data like marks["Asha"] = 90. Keys map to values. Loop with .items() when you need both.

dict.values() — output — [90, 85].

Trap for dict.values() — writing d[missing] in a viva. Prefer get when the key might not exist.

Diagram
{ "Asha": 90, "Ravi": 85 }
         │           │
        key        value
Exam tip

get vs [] — one sentence + tiny dict of marks.

Example

# dict.values()
print(list({"Asha": 90, "Ravi": 85}.values()))

dict.values() — output: [90, 85].

Short notes

  • Defdict.values() works on a dictionary.
  • Ruledict.values() — get when key may miss.
  • Rememberdict.values() — items() → key and value.
  • Trapdict.values() — d[missing] → KeyError.

Questions

1

Explain dict.values() as if you are teaching a junior — definition, then one tiny script.

2

What does the example print, and why?

3

What mistake do freshers make with dict.values()?

Previous← dict.pop()Nextdict.setdefault() →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.