List of all values

EasyDictionary Programs · 86 of 94

Write a Python program to get a list of all values.

Advertisement
Input
{"sqa": 1, "tools": 2, "is": 2, "best": 4}
Output
[1, 2, 2, 4]

Approach

  1. list(d.values()).

Solution

Python
print(list({"sqa": 1, "tools": 2, "is": 2, "best": 4}.values()))
Output
[1, 2, 2, 4]
Advertisement

Learn the concept

New to this topic? Read the lesson, then come back.

More dictionary programs

← All 94 Dictionary Programs