input: Write a python function to extract and print all titles from a webpage given a URL and a class name using BeautifulSoup.
  assert extract_titles("http://example.com", "article-title") == ['Title1', 'Title2', 'Title3']
  assert extract_titles("http://example.com", "news-title") == ['News1', 'News2']
  assert extract_titles("http://example.com", "post-title") == ['Post1', 'Post2', 'Post3']
output: def extract_titles(url, class_name):
      import requests
      from bs4 import BeautifulSoup
  
      response = requests.get(url)
      soup = BeautifulSoup(response.content, "html.parser")
      titles = [element.get_text() for element in soup.find_all(class_=class_name)]
      return titles