Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c53a894

Browse files
committed
d.items() -> list(d.items()) in the examples
1 parent 2e4b0e1 commit c53a894

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Doc/library/collections.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ sequence of key-value pairs into a dictionary of lists:
538538
>>> for k, v in s:
539539
... d[k].append(v)
540540
...
541-
>>> d.items()
541+
>>> list(d.items())
542542
[('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
543543

544544
When each key is encountered for the first time, it is not already in the
@@ -553,7 +553,7 @@ simpler and faster than an equivalent technique using :meth:`dict.setdefault`:
553553
>>> for k, v in s:
554554
... d.setdefault(k, []).append(v)
555555
...
556-
>>> d.items()
556+
>>> list(d.items())
557557
[('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
558558

559559
Setting the :attr:`default_factory` to :class:`int` makes the
@@ -565,7 +565,7 @@ languages):
565565
>>> for k in s:
566566
... d[k] += 1
567567
...
568-
>>> d.items()
568+
>>> list(d.items())
569569
[('i', 4), ('p', 2), ('s', 4), ('m', 1)]
570570

571571
When a letter is first encountered, it is missing from the mapping, so the
@@ -592,7 +592,7 @@ Setting the :attr:`default_factory` to :class:`set` makes the
592592
>>> for k, v in s:
593593
... d[k].add(v)
594594
...
595-
>>> d.items()
595+
>>> list(d.items())
596596
[('blue', set([2, 4])), ('red', set([1, 3]))]
597597

598598

0 commit comments

Comments
 (0)