[issue46224] doc: Fix bisect example using mutable function default
Dennis Sweeney
report at bugs.python.org
Sun Jan 2 10:51:20 EST 2022
Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:
Another option would be to use globals:
>>> BREAKPOINTS = [60, 70, 80, 90]
>>> GRADES = "FDCBA"
>>> def grade(score):
... i = bisect(BREAKPOINTS, score)
... return GRADES[i]
...
>>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]
['F', 'A', 'C', 'C', 'B', 'A', 'A']
----------
nosy: +Dennis Sweeney
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46224>
_______________________________________
More information about the Python-bugs-list
mailing list