python code
I am getting an key error even when there's a key present.
print (dict_month[0:4])
[{'January': 'Sun'}, {'January': 'Sun'}, {'January': 'Sun'}, {'January': 'Sun'}]
'January' in dict_month
False
'january' in dict_month
False
python code
I am getting an key error even when there's a key present.
print (dict_month[0:4])
[{'January': 'Sun'}, {'January': 'Sun'}, {'January': 'Sun'}, {'January': 'Sun'}]
'January' in dict_month
False
'january' in dict_month
False
Simple one liner :
>>> any(['January' in ele for ele in l])
#driver values :
IN : l = [{'January': 'Sun'}, {'January': 'Sun'}, {'January': 'Sun'}, {'January': 'Sun'}]
OUT : True
The problem with your approach was as A.Joly mentioned, that you have a list of dictionary. Your approach would have been correct for a dictionary.