w3resource

Python: Access dictionary key’s element by index

Python Dictionary: Exercise - 55 with Solution

Write a Python program to access dictionary key's element by index.

Visual Presentation:

Python List: Access dictionary key’s element by index.

Sample Solution:

Python Code:

num = {'physics': 80, 'math': 90, 'chemistry': 86}
print(list(num)[0])
print(list(num)[1])
print(list(num)[2])

Sample Output:

physics
math
chemistry

Flowchart:

Flowchart: Access dictionary key’s element by index

Python Code Editor:

Previous: Write a Python program to get the depth of a dictionary.
Next: Write a Python program to convert a given dictionary into a list of lists.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.