I'm new to python and I'm trying to learn the best ways to write very fast code. I'm working on an exercise of handling nested dictionaries, and here is the dictionary that I'm working with:
{
"key_1": [
{
"title": <title>,
"date": <date>,
"text": <text>
}
],
"key_2": [
{
"title": <title>,
"date": <date>,
"text": <text>
}
],
"key_3": [
{
"title": <title>,
"date": <date>,
"text": <text>
}
]
}
Here is the code that I've written to access it. But because I have three nested for loops, I don't think this is as fast as it could be:
for main_key, main_value in dictionary.items():
if main_value:
for value in main_value:
for sub_keys, sub_values in value.items():
if sub_keys == "date":
print(sub_values)
Any pointers on how I can make my code both more concise and faster? Thanks a lot in advance!