avatar Bite 297. Rename keys

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.

 

Login and get coding
go back Advanced level
Bitecoin 4X

48 out of 54 users completed this Bite.
Will you be Pythonista #49 to crack this Bite?
Resolution time: ~50 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 5.75 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help