You are viewing a single comment's thread. Return to all comments →
I think here is a simpler way to solve this problem. Change the last character to the next character than subtract left from right:
left = bisect.bisect_left(contacts, contact) prefix_next = contact[:-1] + chr(ord(contact[-1])+1) right = bisect.bisect_left(contacts, prefix_next) print right-left
Seems like cookies are disabled on this browser, please enable them to open this website
Tries: Contacts
You are viewing a single comment's thread. Return to all comments →
I think here is a simpler way to solve this problem. Change the last character to the next character than subtract left from right: