belongs to collection: Python Dictionary Exercises
Write a program to rename a key city to a location in the following dictionary.
city
location
Given:
sample_dict = { "name": "Kelly", "age":25, "salary": 8000, "city": "New york" }
Expected output:
{'name': 'Kelly', 'age': 25, 'salary': 8000, 'location': 'New york'}
Hint:
Solution:
sample_dict = { "name": "Kelly", "age": 25, "salary": 8000, "city": "New york" } sample_dict['location'] = sample_dict.pop('city') print(sample_dict)
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Hint:
Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer