I have a python dictionary object that will get value by a user. Also the user may leave it as None
.
I want to check if my dict has a specific key or not, I tried if key in dict
but I got argument of type 'NoneType' is not iterable
error when my dict is None
.
I need one line statement that returns False
either my dict is None
or my dict does not have that key.
Here is my code: (form is the dictionary)
if 'key' not in form:
# Do somethin