I wrote a little bit code try to search a word in a list. It's not the final version and basically it can't do anything yet. However, I don't understand what was wrong with the code:
def findword (word, t):
t.sort()
midword = t[len(t)/2]
midindex = len(t)/2
if word > midword:
del t[:midindex]
findword (word, t)
elif word < midword:
del t[midindex+1:]
findword (word, t)
elif word == midword:
return t
else:
return None
mydic=['apple','banana','peach','pear','melon','lemon','grape','berry']
mydic1 = findword('apple', mydic)
I got a RuntimeError: maximum recursion depth exceeded in cmp error when tried to search apple and when I search the other words in the list, it returns empty list.
Please help me figure out what was wrong. Thanks!
__floordiv__instead of__truediv__!!