List of all keys

EasyDictionary Programs · 85 of 94

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

Advertisement
Input
{"sqa": [1, 2, 5, 6], "tools": [3, 8, 9], "is": [2, 5, 0], "best": [3, 6, 8]}
Output
['sqa', 'tools', 'is', 'best']

Approach

  1. list(d).

Solution

Python
print(list({"sqa": [1, 2, 5, 6], "tools": [3, 8, 9], "is": [2, 5, 0], "best": [3, 6, 8]}))
Output
['sqa', 'tools', 'is', 'best']

Learn the concept

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

More dictionary programs

← All 94 Dictionary Programs