(Dec-01-2020, 05:56 PM)bowlofred Wrote:When i changed the target to 111, the program returned 140. Why if in that list there is a 100, which is smaller than 111, and 140 isn't.(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.
Find _ in a list
Messages In This Thread |
Find _ in a list - by 1234 - Nov-30-2020, 04:31 PM
RE: Find _ in a list - by deanhystad - Nov-30-2020, 04:44 PM
RE: Find _ in a list - by 1234 - Nov-30-2020, 07:21 PM
RE: Find _ in a list - by deanhystad - Nov-30-2020, 08:16 PM
RE: Find _ in a list - by bowlofred - Nov-30-2020, 08:36 PM
RE: Find _ in a list - by 1234 - Dec-01-2020, 03:19 PM
RE: Find _ in a list - by bowlofred - Dec-01-2020, 04:51 PM
RE: Find _ in a list - by 1234 - Dec-01-2020, 05:45 PM
RE: Find _ in a list - by bowlofred - Dec-01-2020, 05:56 PM
RE: Find _ in a list - by 1234 - Dec-01-2020, 06:33 PM
RE: Find _ in a list - by deanhystad - Dec-01-2020, 05:48 PM
RE: Find _ in a list - by 1234 - Dec-01-2020, 06:35 PM
RE: Find _ in a list - by bowlofred - Dec-01-2020, 07:13 PM
RE: Find _ in a list - by deanhystad - Dec-01-2020, 07:05 PM
RE: Find _ in a list - by 1234 - Dec-01-2020, 07:20 PM
RE: Find _ in a list - by bowlofred - Dec-01-2020, 07:53 PM
|
Users browsing this thread: 2 Guest(s)