input: Write a python function to search for a term on Reddit and return the titles of the posts.
  assert reddit_search('Machine Learning')!=[]
  assert isinstance(reddit_search('Python'), list)
  assert len(reddit_search('AI')) > 0
output: import requests
  
  def reddit_search(term):
      url = f'https://www.reddit.com/search.json?q={term}'
      headers = {'User-agent': 'Mozilla/5.0'}
      response = requests.get(url, headers=headers)
      data = response.json()
      titles = [post['data']['title'] for post in data['data']['children']]
      return titles