Reputation: 16691
I have the following which works well for matching a key within a dictionary.
if mydict.__contains__('bananas'): print "found"
Is there a way to base the if on the logic that the string is not found
if
Upvotes: 0
Views: 458
Reputation:
This is possible:
if "bananas" not in mydict: print "not found"
Upvotes: 8