Rename keys
Level: Advanced (score: 4)
The Data Processing Department was writing a script to import some json data into Python dictionaries for analysis, but their program has a bug!
Some of the dictionary keys start with @
symbols and the Accounting Department will have none of this.
Complete the rename_keys()
function to remove the @
character from the beginning of the dictionary key names(Warning: Not all the dictionary keys are strings.)
You should return a new dictionary object and NOT modify the input data in place.
Example:
>>> rename_keys({'@user_name': 'jdoe'})
{'user_name': 'jdoe'}
Note: The input data maybe a deeply nested structure, take a look at the tests for examples.