Converted search.c to python, making it slightly more pythonic