Implemented a random search in Python