def linear_search(theList, x): i = 0 while i < len(theList): if theList[i] == x: return True i = i + 1 return False def binary_search(theList, x): lo = 0 hi = len(theList) while lo < hi: mid = (lo + hi)/2 if theList[mid] == x: return True if theList[mid] < x: lo = mid + 1 else: hi = mid return False print linear_search(["Apfel", "Pfirsich", "Birne"], "Apfel") print linear_search(["Apfel", "Pfirsich", "Birne"], 7) print binary_search([2, 5, 7, 11], 9)