I'm aware that many questions of the kind were posted here, but I couldn't find one that matches my case.
I have a list made up of dictionaries, where each dictionary contains only a single key, and a list as its value. For example: keyList = [{'key1': [1,2,3]}, {'key2': [3, 4, 5]}, ...]
Now, I want to create a simple function which receives two arguments: an aforementioned list, and a key, and returns a matching dictionary from a given list.
the function is:
def foo(someKey, someList):
for i in someList:
if str(i.keys()).lower() == str(someKey).lower():
return i
When called: foo('key1', keyList), the function returned the None object (instead of {'key1': [1,2,3]}.
The two compared values have the the same length and are of the same type (<type 'str'>), yet a comparison yields a False value.
Thanks for advance for any assistance or/and suggestions as to the nature of the problem.