I need to make a dictionary containing only keys.
I cannot use d.append()
as it is not a list, neither setdefault
as it needs 2 arguments: a key and a value.
It should work as the following:
d = {}
add "a":
d = {"a"}
add "b":
d = {"a", "b"}
add "c"...
# Final result is:
d = {"a", "b", "c"}
What is the code I need to get this result? Or is it another solution? Such as making a list.
l = ["a", "b", "c"] # and transform it into a dictionary: d = {"a", "b", "c"} ?