From d44b888aeb04315375f6d433363abc984baf0d56 Mon Sep 17 00:00:00 2001 From: Harshil Darji Date: Tue, 26 Jul 2016 22:23:22 +0530 Subject: [PATCH] Minor improvement --- BinarySeach.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BinarySeach.py b/BinarySeach.py index b4828c64c..9d09c6ba3 100644 --- a/BinarySeach.py +++ b/BinarySeach.py @@ -9,7 +9,7 @@ def binarySearch(alist, item): midpoint = (first + last)//2 if alist[midpoint] == item: found = True - print("Found") + print("Found [ at position: %s ]" % (alist.index(item) + 1)) else: if item < alist[midpoint]: @@ -17,9 +17,10 @@ def binarySearch(alist, item): last = midpoint-1 else: first = midpoint+1 + if found == False: - - print("Not found") + continue + # print("Not found") return found print("Enter numbers seprated by space") s = input()