Created
August 5, 2020 17:22
-
-
Save raeq/1d61d7f5948217a596878a97cee26d5d to your computer and use it in GitHub Desktop.
Invert dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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