Learning Is Never Ending Process
Solution
You can use dict.get()
dict.get()
value = d.get(key)
which will return None if key is not in d. You can also provide a different default value that will be returned instead of None:
None
key is not in d
value = d.get(key, "empty")
No comments:
Post a Comment