input: Write a function to scrape an online news website to get the headlines. The function should take the URL of the website as input, fetch the webpage, parse it using BeautifulSoup, and print all headlines found in <h2> tags.
  
  assert scrape_headlines("https://www.news.com/")==[print output of headlines]
  assert scrape_headlines("https://www.anothernews.com/")==[print output of headlines]
  assert scrape_headlines("https://www.invalidurl.com/")==[handle invalid URL scenario]
output: def scrape_headlines(url):
      try:
          import requests
          from bs4 import BeautifulSoup
          response = requests.get(url)
          response.raise_for_status()
          soup = BeautifulSoup(response.text, 'html.parser')
          headlines = soup.find_all('h2')
          for headline in headlines:
              print(headline.text)
      except Exception as e:
          print(f"Error: {e}")