how we access this dictionary key,values india{"Newdelhi":{"delhi":"captial", "maharastra":heritage", "telangana:Hyderabad"}, "gujarat":{"aaaamabad":"captial", "raipur":"river"}}"
Hi there. Thanks for the vid. Would you be so kind to tell me why my code is not working? I need to compare the dates from the dictionaries with the day given as "current". Also please explain why the output is printed twice (8 lines for 4 dictionaries in the list "opts". # input opts=[ {"type":"buy","date":"2020/12/15"}, {"type":"buy","date":"2020/12/15"}, {"type":"sell","date":"2020/12/14"}, {"type":"sell","date":"2020/12/16"} ] current = "2020/12/15" for dictionary in opts: for key in dictionary: if key[1] < current: print('option expired') elif key[1] > current: print('option expires in future') else: print('option expires today') # output option expires in future option expires in future option expires in future option expires in future option expires in future option expires in future option expires in future option expires in future Thank you for the help.
Hands down, the easiest explanation on nested dictionaries.
this is the best video about nested dictionaries I've founded,thank you
I swear this is the only good video on this topic 😂 Thanks so much, dude.
Thank you! This is common with api json, databases, and CSVs. This was the most straight forward example I have seen 🙌🏾
Brilliantly demonstrated a complicated topic.
Well Explained in simple words. Thanks for the content.
Thanks! This explained how to loop list/dictionaries perfectly. Awesome video!
Thanks alot for this video. I was really confused esp when it came to using the .items() method/function.
You cleared it all up💪🏽
Brillant!!!!
How would you print the secondary keys/values for each key, sorted by a chosen secondary key? E.g print each record sorted by age
how can i insert the result of the:
for key in unit:
for value in key:
print(value,":", key[value])'
in a dictionary paython?
What if you want to output lets say only names
how we access this dictionary key,values
india{"Newdelhi":{"delhi":"captial", "maharastra":heritage", "telangana:Hyderabad"},
"gujarat":{"aaaamabad":"captial", "raipur":"river"}}"
Hi there. Thanks for the vid. Would you be so kind to tell me why my code is not working?
I need to compare the dates from the dictionaries with the day given as "current".
Also please explain why the output is printed twice (8 lines for 4 dictionaries in the list "opts".
# input
opts=[
{"type":"buy","date":"2020/12/15"},
{"type":"buy","date":"2020/12/15"},
{"type":"sell","date":"2020/12/14"},
{"type":"sell","date":"2020/12/16"}
]
current = "2020/12/15"
for dictionary in opts:
for key in dictionary:
if key[1] < current:
print('option expired')
elif key[1] > current:
print('option expires in future')
else:
print('option expires today')
# output
option expires in future
option expires in future
option expires in future
option expires in future
option expires in future
option expires in future
option expires in future
option expires in future
Thank you for the help.
For dictionary in opts :
for _ in dictionary :
If dictionary [date] < current :