Is there a single-line technique that returns the location at which a value would fit into a sorted sequence of values? /u/OhGodSoManyQuestions Python Education

For instance: sorted_values = [2,4,8,16,32,64,128,256,512,1024] new_value = 23 answer: position 4, because 23 would sort between 16 and 32 I know how to do this with loops and comparison, of course. Or by inserting it into a copy of the sequence and finding the position of that value. But it seems like the kind of thing Python would have a single special function for. 

submitted by /u/OhGodSoManyQuestions
[link] [comments]

​r/learnpython For instance: sorted_values = [2,4,8,16,32,64,128,256,512,1024] new_value = 23 answer: position 4, because 23 would sort between 16 and 32 I know how to do this with loops and comparison, of course. Or by inserting it into a copy of the sequence and finding the position of that value. But it seems like the kind of thing Python would have a single special function for. submitted by /u/OhGodSoManyQuestions [link] [comments] 

For instance: sorted_values = [2,4,8,16,32,64,128,256,512,1024] new_value = 23 answer: position 4, because 23 would sort between 16 and 32 I know how to do this with loops and comparison, of course. Or by inserting it into a copy of the sequence and finding the position of that value. But it seems like the kind of thing Python would have a single special function for. 

submitted by /u/OhGodSoManyQuestions
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *