+ 1

How to print only values in a dictionary? Eg: d={'US':{'CA':44 },'IND':{'KA':91} } Output should be only 44 and 92....?

How to print only values in a dictionary? Eg: d={'US':{'CA':44 },'IND':{'KA':91} } Output should be only 44 and 92....?

14th Aug 2018, 5:20 AM
Vinay Kumar.M
Vinay Kumar.M - avatar
4 Respostas
+ 3
You could use key, value twice or use the get method. I worked it out in the code below. https://code.sololearn.com/c91BS9fz99r9/?ref=app
14th Aug 2018, 6:14 AM
davy hermans
davy hermans - avatar
+ 2
Take a look at the second solution. It doesn't require the element names.
14th Aug 2018, 6:25 AM
davy hermans
davy hermans - avatar
0
What if I don't know the elements names in the dictionary....??? I want it to be more generic way...
14th Aug 2018, 6:22 AM
Vinay Kumar.M
Vinay Kumar.M - avatar
0
Thank you so much davy hermans
14th Aug 2018, 6:36 AM
Vinay Kumar.M
Vinay Kumar.M - avatar