Dec-01-2020, 05:56 PM
(Dec-01-2020, 05:45 PM)1234 Wrote: And what if my target is 100 and there is no 100 in the list, so I want to take the closest number to 100 that is smaller than 100?
The program didn't return 100 (because 100 isn't less than 100). It returned the largest number less than 100.
You can read more about the specifics of bisect (which allow you to quickly find things in a sorted list, and to append things in a way that keeps a list sorted) in the docs.