Skip to content

Instantly share code, notes, and snippets.

@remilapeyre
Created August 28, 2019 16:00
Show Gist options
  • Save remilapeyre/eb8e7e5ced712a251efed91b168d3ae4 to your computer and use it in GitHub Desktop.
Save remilapeyre/eb8e7e5ced712a251efed91b168d3ae4 to your computer and use it in GitHub Desktop.
dict.py
# Write a function `replace_dashes` that takes a
# dictionnary as input and rename the keys so that
# every '_' is replaced by '-'.
# Your function should not change the values, for
# example, if the input is:
# {
# "key_1": "value_1",
# "key_2": "value_2",
# "key_3": {
# "key_4": "value_4"
# }
# }
# its output should be:
# {
# "key-1": "value_1",
# "key-2": "value_2",
# "key-3": {
# "key-4": "value_4"
# }
# }
print(replace_dashes({
"key-1": "value_1",
"key-2": "value_2",
"key-3": {
"key-4": "value_4"
}
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment