input: Write a function to implement a Python script that scrapes photos and captions from a given website. The function should take a URL as input, fetch the HTML source code, parse it using BeautifulSoup, and then extract and print the URLs of the photos along with their captions if available. If no caption exists, it should print "No caption". The function should also handle cases where the HTML structure is not as expected.
  
  def scrape_photos_and_captions(url):
      from bs4 import BeautifulSoup
      import requests
  
      # Get the HTML source code
      req = requests.get(url)
      html = req.text
  
      # Parse HTML source and extract photo and caption
      soup = BeautifulSoup(html, features='lxml')
      image_divs = soup.find_all('div', {'class': 'image-gallery__image'})
  
      for image_div in image_divs:
          figure = image_div.find('figure')
          if figure:
              src = figure.find('img')['src'] if figure.find('img') else 'No image found'
              caption = figure.find('figcaption')
              print('Photo: ', src)
              if caption:
                  print('Caption: ', caption.text)
              else:
                  print('No caption')
              print('\n')
  
  assert scrape_photos_and_captions('https://example.com/webpage1') == """Photo: https://example.com/image1.jpg
  Caption: This is the first image
  
  Photo: https://example.com/image2.jpg
  No caption
  
  """
  assert scrape_photos_and_captions('https://example.com/webpage2') == """Photo: https://example.com/image3.jpg
  Caption: This is another image
  
  Photo: https://example.com/image4.jpg
  No caption
  
  """
  assert scrape_photos_and_captions('https://example.com/webpage3') == """Photo: https://example.com/image5.jpg
  Caption: Yet another image
  
  Photo: https://example.com/image6.jpg
  No caption
  
  """
  assert scrape_photos_and_captions('https://example.com/webpage4') == """Photo: No image found
  No caption
  
  """
  assert scrape_photos_and_captions('https://example.com/webpage5') == """Photo: https://example.com/image7.jpg
  Caption: Final image
  
  Photo: https://example.com/image8.jpg
  No caption
  
  """
output: def scrape_photos_and_captions(url):
      from bs4 import BeautifulSoup
      import requests
  
      # Get the HTML source code
      req = requests.get(url)
      html = req.text
  
      # Parse HTML source and extract photo and caption
      soup = BeautifulSoup(html, features='lxml')
      image_divs = soup.find_all('div', {'class': 'image-gallery__image'})
  
      for image_div in image_divs:
          figure = image_div.find('figure')
          if figure:
              src = figure.find('img')['src'] if figure.find('img') else 'No image found'
              caption = figure.find('figcaption')
              print('Photo: ', src)
              if caption:
                  print('Caption: ', caption.text)
              else:
                  print('No caption')
              print('\n')