from collections import defaultdict
# Defining the dict and passing
# lambda as default_factory argument
d = defaultdict(lambda c: "Not Present")
d["a"] = 1
d["b"] = 2
print(d["a"])
print(d["b"])
print(d["c"])
I expected a right outcome Everything sounds right Please check whats wrong with C lambda
The problem is the "c" in the lambda. You should use defaultdict like that:
when you put a word after
lambda, it's an argument. Exemple: