fruit={'apple':'one','banana':'two','orange':'three'}
a='one'
if a in fruit.value():
print(a,"was found!")
When I run this on python it shows: AttributeError: 'dict' object has no attribute 'value'
fruit={'apple':'one','banana':'two','orange':'three'}
a='one'
if a in fruit.value():
print(a,"was found!")
When I run this on python it shows: AttributeError: 'dict' object has no attribute 'value'
The dictionary has no element called key(). What you're meant to use is keys() with an s at the end. This is how it should look like:
fruit={'apple':'one','banana':'two','orange':'three'}
a='apple'
if a in fruit.keys():
print(f"Yes, key: '{a}' exists in dictionary")
Simply check it like this:
fruit={'apple':'one','banana':'two','orange':'three'}
a='apple'
if a in fruit:
print(a,"was found!")