Basic binary search in python I just started learning to code during quarantine and whilst learning python, I created this program for a binary search. This is really basic so I assume that there is a way easier method. If anyone knows how I can make this way simpler, your help would be appreciated. 

list = [1,15,37,53,29,22,31,90,14,6,37,40]
finished = False
target = 37
list.sort()
print(list)
while finished == False:
    n = len(list)
    print(n)
    if target &lt; list[int(n/2)]:
        for items in range(int(n / 2), n):
            list.pop()
        print('Item is too large.')
    elif target == list[int(n/2)]:
        finished = True
        print('The item has been found.')
    else:
        list.reverse()
        for items in range(int(n / 2), n):
            list.pop()
        list.reverse()
        print('Item is too small.')
    print(list)
Avoid using list as the variable name, because it is a
function in Python.  
You don't need to manipulate the list, such
as list.pop() and    list.reverse(). It is inefficient. You can
determine the updated search range with index.   
When target is assigned a value not within list, there will be IndexError: list index out of range. It means you didn't handle the case well.


Modified code: 

search_list = [1,15,37,53,29,22,31,90,14,6,37,40]
target = 37
start = 0
end = len(search_list)-1 
search_list.sort()
print('The sorted list:',search_list)
while start&lt;=end:
    n = int((end + start)/2)
    if target &lt; search_list[n]: # the target is small 
        end = n-1
    elif target &gt; search_list[n]: # the target is large 
        start = n+1
    elif target == search_list[n]: # the target is found 
        print('The item {} has been found at the index {} in the sorted list.'.format(target,n))
        break 
else:
    print('The item is not found.')