Posted on 27th April 2024
I will give you an example to rename a dictionary key using a naive method there are different methods to do this but I fell naive method is very easy so have a look
ini_dict = {'Akhil': 1, 'vissu' : 5,
'Nikita' : 10, 'deepu' : 15}
print ("initial dictionary", ini_dict)
ini_dict['Akhil'] = ini_dict['Akshay']
del ini_dict['Akshay']
print ("final dictionary", str(ini_dict))
Output:
initial dictionary{‘Akhil’:1, ‘deepu’:15, ‘vissu’:5, ‘Nikitha’:10}
final dictionary {‘Akshay’:1, ‘deepu’:15, ‘vissu’:5, ‘Nikitha’:10}
STILL GOT QUERIES?