You can use 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
:
value = d.get(key, "empty")
You can use 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
:
value = d.get(key, "empty")
For further actions, you may consider blocking this person and/or reporting abuse
Peter Truchly -
Víctor Falcón -
Aarav Joshi -
Alona Potapova -
Top comments (0)