[doc] Remove duplicated operator.itemgetter example (GH-24178) (#25646)

* Remove duplicated itemgetter example
* Add spaces
(cherry picked from commit 743e2bae10)

Co-authored-by: Andre Delfino <adelfino@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-04-26 21:16:40 -07:00 committed by GitHub
parent c816c1c779
commit 4a3d73d8ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -315,15 +315,12 @@ expect a function argument.
method. Dictionaries accept any hashable value. Lists, tuples, and
strings accept an index or a slice:
>>> itemgetter('name')({'name': 'tu', 'age': 18})
'tu'
>>> itemgetter(1)('ABCDEFG')
'B'
>>> itemgetter(1,3,5)('ABCDEFG')
>>> itemgetter(1, 3, 5)('ABCDEFG')
('B', 'D', 'F')
>>> itemgetter(slice(2,None))('ABCDEFG')
>>> itemgetter(slice(2, None))('ABCDEFG')
'CDEFG'
>>> soldier = dict(rank='captain', name='dotterbart')
>>> itemgetter('rank')(soldier)
'captain'