a=[]
f=0

print("BINARY SEARCH")
print("ENTER NUMBERS IN ASCENDING ORDER")
for i in range(0,9):
    k=int(input("ENTER THE ELEMENT AT ["+ str(i+1) +"]: "))
    a.append(k)
s=int(input("ENTER A NUMBER TO BE SEARCHED: "))
#print(a[1])
#exit()
l=0
u=9
while[ l <= u ]:
    m=int( (l + u) / 2)
    if s==a[m]:
        f=1
        break
    elif s>a[m]:
        l = m + 1
    else:
        u = m - 1

if f==1:
    print("FOUND "+str(s)+" at location "+str(m+1))
else:
    print("NOT FOUND")

"NOT FOUND DOES NOT WORK"

You have list with value for while condition, which is never empty, so this while never terminates in case of not found. Remove []

No need to shout with CAPITALIZEd words.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.