There was an error while loading. Please reload this page.
2 parents a812c56 + 19107af commit e6bec94Copy full SHA for e6bec94
Status/Day_17.md
@@ -125,7 +125,26 @@ print bin_search(li,12)
125
#to be written
126
127
```
128
-
+**Solution by ulmasovjafarbek: Python 3**
129
+```python
130
+def binary_search(lst, item):
131
+ low = 0
132
+ high = len(lst) - 1
133
+
134
+ while low <= high:
135
+ mid = round((low + high) / 2)
136
137
+ if lst[mid] == item:
138
+ return mid
139
+ elif lst[mid] > item:
140
+ high = mid - 1
141
+ else:
142
+ low = mid + 1
143
+ return None
144
145
+lst = [1,3,5,7,]
146
+print(binary_search(lst, 9))
147
+```
148
---
149
150
**Solution by AasaiAlangaram: Python 3**
0 commit comments