How would one access a value from a dictionary inside a dictionary?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By slightly_seasoned

Hey there, I’m trying to access a value from a dictionary inside a dictionary like this: dictionary["another_dictionary"["value"]], but I get an error saying invalid index in constant expression. How would one access a value from a dictionary inside a dictionary?

For future reference this is called a nested dictionary value

Wakatta | 2021-10-01 01:10

:bust_in_silhouette: Reply From: r.bailey

From your example try,

dictionary["another_dictionary"]["value"]

if “value” has multiple levels it would just continue on that way. i.e

dictionary["another_dictionary"]["value"]["valueofvalue"]

Hope this helps.