My take on a binary search algorithm without research or knowledge of an efficient one. It would be appreciated if one could show me an efficient way to do it using recursion or a more pythonic approach.
from math import *
numList = [i for i in range(11)]
while True:
try:
beginning = 0
end = len(numList) - 1
mid = floor(((end-beginning)/2) + beginning)
value = int(input("What value would you like to search for?: "))
notFound = True
while notFound:
if value > end or value < beginning:
print("The value is not in the list")
break
elif value == mid:
print("The value is in the list")
print("The index is " + str(mid))
notFound = False
elif value == end:
print("The value is in the list")
print("The index is " + str(end))
notFound = False
elif value > mid:
beginning = mid
mid = floor(((end-beginning)/2) + beginning)
elif value < mid:
end = mid
mid = floor(((end-beginning)/2) + beginning)
except ValueError:
print("Invalid characters")
```