# Binary Search

def main():
    mySortedList = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
    itemToFind = 7
    print(binarySearch(mySortedList,itemToFind))
    
def binarySearch(sortedList, item):
    first = 0
    last = len(sortedList) - 1
    found = False

    while(first <= last and not found):
        midpoint = round((first + last) / 2)
        
        if(sortedList[midpoint] == item):
            found = True
        else:
            if(item < sortedList[midpoint]):
                last = midpoint-1
            else:
                first = midpoint + 1
    return found 

main()

