Answers for "lowercase keys of dictionary python"

0

python code to convert all keys of dict into lowercase

my_dict = {'KEY1': "Hello", 'Key2': "World"} 
new_dict = dict((k.lower(), v) for k, v in my_dict .items()) 
print(new_dict
Posted by: Guest on December-08-2020
0

convert dictionary keys/values to lowercase in python

my_dict = {'KEY1': "Hello", 'Key2': "World"} 
new_dict = dict((k, v.lower()) for k, v in my_dict .items()) 
print(new_dict)
Posted by: Guest on June-22-2021
0

convert dictionary keys/values to lowercase in python

def lower_dict(d):
   new_dict = dict((k.lower(), v.lower()) for k, v in d.items())
   return new_dict
a = {'Foo': "Hello", 'Bar': "World"}
print(lower_dict(a))
Posted by: Guest on June-22-2021

Code answers related to "lowercase keys of dictionary python"

Python Answers by Framework

Browse Popular Code Answers by Language