a = 132
b = [0, 10, 30, 60, 100, 150, 210, 280, 340, 480, 530]
I want to know that a should be in the 6th position in ordered list b.
What’s the most pythonic way to do so?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use bisect. It’s not the most beautiful API, but it’s exactly what you need.
You’ll want to use
bisect.bisect, which returns exactly what you want.