You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For Python 3.7 dictionaries maintain the insertion order of the items. While looping over *items()* method,
367
-
you will get the key/value combination based on the insertion order of those items.
368
-
369
350
Many times it happens that we want to add more data to a value in a dictionary and if the key does not exists then we add some default value. You can do this efficiently using *dict.setdefault(key, default)*.
370
351
::
371
352
@@ -391,6 +372,45 @@ When we try to get value for a key which does not exists we get *KeyError*. We c
391
372
>>> data.get('foo', 0)
392
373
0
393
374
375
+
376
+
Looping over a dictionary
377
+
--------------------------
378
+
379
+
If you just do a `for` loop over a dictionary, it will provide you all the available keys in the dictionary.
0 commit comments