Adding docttest to to_zero_count()
This commit is contained in:
parent
62b29678a6
commit
fc9c721d96
1 changed files with 6 additions and 0 deletions
|
@ -21,6 +21,11 @@ def to_zero_count(page_no):
|
||||||
"""
|
"""
|
||||||
Will subtract 1 from the argument it gets, converting it to an int.
|
Will subtract 1 from the argument it gets, converting it to an int.
|
||||||
If the conversion fails or the argument it's negatives it returns zero instead.
|
If the conversion fails or the argument it's negatives it returns zero instead.
|
||||||
|
|
||||||
|
>>> to_zero_count(3)
|
||||||
|
2
|
||||||
|
>>> to_zero_count('a')
|
||||||
|
0
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
page_no: An integer
|
page_no: An integer
|
||||||
|
@ -28,6 +33,7 @@ def to_zero_count(page_no):
|
||||||
Returns:
|
Returns:
|
||||||
It returns page_no - 1 if page_no can be safely converted to an integer else it returns zero.
|
It returns page_no - 1 if page_no can be safely converted to an integer else it returns zero.
|
||||||
If page_no is negative, it returns zero.
|
If page_no is negative, it returns zero.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
page_no = int(page_no) - 1
|
page_no = int(page_no) - 1
|
||||||
|
|
Loading…
Reference in a new issue