input: Write a function to generate an HTML table displaying information about the top 10 bestselling books in a specific genre. The function should connect to a SQLite database, retrieve the relevant data, and then construct an HTML table from that data.
  
  
  def generate_bestseller_table(genre):
      import sqlite3
  
      # connect to the database
      conn = sqlite3.connect('books.db')
      c = conn.cursor()
  
      # retrieve the data
      c.execute(f'''SELECT title, author, sales
                   FROM Books
                   WHERE genre=?
                   ORDER BY sales DESC
                   LIMIT 10''', (genre,))
  
      # save the results
      results = c.fetchall()
  
      # generate the HTML code
      html = '<table>'
      html += '<tr><th>Title</th><th>Author</th><th>Sales</th></tr>'
  
      for result in results:
          title = result[0]
          author = result[1]
          sales = result[2]
  
          html += f'<tr><td>{title}</td><td>{author}</td><td>{sales}</td></tr>'
  
      html += '</table>'
  
      # close the connection
      conn.close()
  
      return html
  
  assert generate_bestseller_table('Fantasy').startswith('<table><tr><th>Title</th><th>Author</th><th>Sales</th></tr>') == True
  assert generate_bestseller_table('Mystery') != ""
  assert generate_bestseller_table('Sci-Fi').count('<tr>') > 0
  assert generate_bestseller_table('') == '<table><tr><th>Title</th><th>Author</th><th>Sales</th></tr></table>'
  
output: def generate_bestseller_table(genre):
      import sqlite3
  
      conn = sqlite3.connect('books.db')
      c = conn.cursor()
  
      c.execute(f'''SELECT title, author, sales
                   FROM Books
                   WHERE genre=?
                   ORDER BY sales DESC
                   LIMIT 10''', (genre,))
  
      results = c.fetchall()
  
      html = '<table>'
      html += '<tr><th>Title</th><th>Author</th><th>Sales</th></tr>'
  
      for result in results:
          title = result[0]
          author = result[1]
          sales = result[2]
  
          html += f'<tr><td>{title}</td><td>{author}</td><td>{sales}</td></tr>'
  
      html += '</table>'
  
      conn.close()
  
      return html