Skip to content

Instantly share code, notes, and snippets.

@raeq
Created August 5, 2020 17:22
Show Gist options
  • Save raeq/1d61d7f5948217a596878a97cee26d5d to your computer and use it in GitHub Desktop.
Save raeq/1d61d7f5948217a596878a97cee26d5d to your computer and use it in GitHub Desktop.
Invert dictionary
def invert_dictionary(input:dict)->dict:
return {v: k for k, v in dict1.items()}
dict1 = {"a": 1, "b": 2, "c": 3}
assert invert_dictionary(dict1) == {1: "a", 2: "b", 3: "c"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment