this is what i have done but this only locates one item in the list i want to print out both indices of item 36 please help this is what i have done so far if the way i posted this or my question isn't clear i apologize in advance [code]
def main():
mylist=[]
for i in range(20):
mylist.append(i*3)
mylist.append(36)
mylist.sort()
print mylist
binarySearch(mylist,0,len(mylist),36)
def binarySearch(thelist,lower,upper,item):
if upper<lower:
print 'item not in the list'
return
middle=(lower+upper)/2
if thelist[middle]<item:
lower=middle+1
binarySearch(thelist,lower,upper,item)
elif thelist[middle]>item:
upper=middle-1
binarySearch(thelist,lower,upper,item)
else:
print 'the item was found at index ',thelist[middle],middle
return
main()