Created
January 6, 2026 12:50
-
-
Save pythonhacker/f2c83a2d91ae792516fc24a997d8d5a4 to your computer and use it in GitHub Desktop.
Demo of the occurrences function using bisect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> l=[10, 12, 15, 17, 18, 20, 20, 21, 21, 21, 24, 24] | |
| >>> occurs(l, 18) | |
| range(4, 5) | |
| >>> occurs(l, 20) | |
| range(5, 7) | |
| >>> list(occurs(l, 21)) | |
| [7, 8, 9] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment