@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 1642 / 12833)
About the function get () that retrieves the elements of the Python Dictionary.
If not, you get the optional value, if you specified one:
>>> pythons.get('Mark', 'Not a Pythong')
'Not a Python'
An example when it is not included in dictionary "pythons".
I've tried.
http://ideone.com/zUP5Pu
mydic = {'7of9' : 'borg', 'Chakotay' : 'human', 'Janeway' : 'human'}
print(mydic.get('7of9', 'unknown'))
print(mydic.get('Chakotay', 'unknown'))
print(mydic.get('Tuvok', 'unknown'))
result
Success time: 0 memory: 23352 signal:0
borg
human
unknown
Recommended Posts