mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Minor doc fixes.
This commit is contained in:
parent
1e884d9f67
commit
11485b4869
3 changed files with 10 additions and 7 deletions
|
@ -1201,8 +1201,8 @@ Samuele
|
|||
... return imap(function, count(start))
|
||||
|
||||
>>> def nth(iterable, n):
|
||||
... "Returns the nth item or empty list"
|
||||
... return list(islice(iterable, n, n+1))
|
||||
... "Returns the nth item or None"
|
||||
... return next(islice(iterable, n, None), None)
|
||||
|
||||
>>> def quantify(iterable, pred=bool):
|
||||
... "Count how many times the predicate is true"
|
||||
|
@ -1318,7 +1318,10 @@ perform as purported.
|
|||
[0, 2, 4, 6]
|
||||
|
||||
>>> nth('abcde', 3)
|
||||
['d']
|
||||
'd'
|
||||
|
||||
>>> nth('abcde', 9) is None
|
||||
True
|
||||
|
||||
>>> quantify(xrange(99), lambda x: x%2==0)
|
||||
50
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue