5 ms·
get() doesn't create a value in the dictionary, though; it only returns a default value. For what you describe, you would want setdefault(). It works here becau
by BrandonM 15y ago
get() doesn't create a value in the dictionary, though; it only returns a default value. For what you describe, you would want setdefault(). It works here because you're assigning a value to a['foo'] after get()ing the default value.