-3

I have this dictionary of lists:

Dict = {'Name':['John','Seth'], 'Gender':['Male','Male'], 'Zip':['68112','22200']}

How to iterate through the keys of this list and make them in lowercase?

The output should be like:

Dict = {'name':['John','Seth'], 'gender':['Male','Male'], 'zip':['68112','22200']} 

I have reviewed the solution by Rich Copeland, but It was not evident to me how to apply.

Any idea how to solve this?

|

I figured out how to fix it! here, use this:

Dict = {'Name':['John','Seth'], 'Gender':['Male','Male'], 'Zip':['68112','22200']}
for key in Dict:
    Dict[key.lower()] = Dict.pop(key)
print(Dict)

~Jack Burch

sorry, the thread was closed so I couldn't comment it.

Community
  • 1
  • 1
MEhsan
  • 2,184
  • 9
  • 27
  • 41

1 Answers1

1

{k.lower(): v for k,v in dict_.iteritems ()}

Julien Goupy
  • 165
  • 6
  • this will only work for python 2.7 + (which is probably fine ...) ... and really doesnt add anything that the answer this was closed as duplicate doesnt cover... it should really be a comment instead of an answer – Joran Beasley Jun 19 '16 at 20:56