Skip to content
Advertisement

How to print Specific key value from a dictionary?

JavaScript

I want to print the kiwi key, how?

JavaScript

This is not working.

Advertisement

Answer

It’s too late but none of the answer mentioned about dict.get() method

JavaScript

In dict.get() method you can also pass default value if key not exist in the dictionary it will return default value. If default value is not specified then it will return None.

JavaScript

fruit dictionary doesn’t have key named cherry so dict.get() method returns default value 99

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement