Python dictionary way get() revisits a worth for the known key. If enter is not obtainable then returns defaulting worth None. Get() technique for dictionaries in Python. In python dictionaries, subsequent is a conformist process to admission a value for a key. ... This way returns the worth for the agreed key is present in the dictionary. If not, then it would revisit None (if get() is utilized with only one argument).
Following is the syntax for get() method:
dict.get(key, default = None)
This method returns a value for the given key. If the key is not available, then returns default value None.
The following example shows the usage of get() method.
#!/usr/bin/python dict = {'Name': 'Zabra', 'Age': 7} print "Value : %s" % dict.get('Age') print "Value : %s" % dict.get('Education', "Never")
When we run the above program, it produces the following result:
Value : 7 Value : Never
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.