list interval index

D

dw

What is the fastest python code to get the index of a huge
list of incrementing interval numbers, given a number?

ie:
ic = [0,10,30,60,90,100,800,1000]
print pyfuncsomething(ic,50) 2
print pyfuncsomething(ic,500)
5

the slower code is like this:

def pyfuncsomething(ic,n):
for i,el in enumerate(ic):
if n > el:
return i
raise Exception, 'Not found'
thx

===========================================================================================
"Gabung INSTANIA, dapatkan XENIA. Daftar di www.telkomnetinstan.com, langsung dapat akses Internet Gratis..
Dan ..ikuti "Instan Smile" berhadiah Xenia,Tour S'pore, Komputer,dll, info hub : TELKOM Jatim 0-800-1-467826 "
===========================================================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top