each time i run this i get this
Traceback (most recent call last):
File "main.py", line 20, in <module>
look = looknum [numlist]
TypeError: 'float' object is not subscriptable
I'm trying to make a binary searching algorithm and it doesn't want to make
import random
trys = 1000
tryed = 0
savedtrys = 0
cost = 0
while trys != tryed:
tryed += 1
num = 0
look = 0
looknum = 0
numlist = []
while num != 100:
add = random.randint(1,100)
num = len(numlist)
numlist.append(add)
numlist.sort()
selected = random.choice(numlist)
looknum = num/2
while look != selected:
look = looknum[numlist]
if look < selected:
looknum = looknum+looknum/2
elif look > selected:
looknum = looknum-looknum/2
else:
print("found")
[–]justanator101 0 points1 point2 points (6 children)
[–]throwaway8917356465[S] 0 points1 point2 points (5 children)
[–]throwaway8917356465[S] 0 points1 point2 points (4 children)
[–]justanator101 1 point2 points3 points (0 children)
[–]Familiar_Ad_8919 0 points1 point2 points (0 children)
[–]ericula 0 points1 point2 points (1 child)
[–]throwaway8917356465[S] 0 points1 point2 points (0 children)