input: Write a function to generate an HTML table displaying information about the top 10 bestselling books in a specific genre from a given database. If there are less than 10 books for that genre, display all available books. If no books match the genre, return an empty table. The function should connect to a SQLite database named 'books.db', retrieve the data, and generate the HTML code as specified. The function should return the generated HTML code.
  
  
  def generate_html_table(genre):
   import sqlite3
  
   # connect to the database
   conn = sqlite3.connect('books.db')
   c = conn.cursor()
  
   # retrieve the data
   c.execute('''SELECT title, author, genre, 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>Genre</th><th>Sales</th></tr>'
  
   for result in results:
       title = result[0]
       author = result[1]
       genre = result[2]
       sales = result[3]
  
       html += f'<tr><td>{title}</td><td>{author}</td><td>{genre}</td><td>{sales}</td></tr>'
  
   html += '</table>'
  
   # close the database connection
   conn.close()
  
   return html
  
  assert generate_html_table('Fantasy')=='<table><tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr><tr><td>The Hobbit</td><td>J.R.R. Tolkien</td><td>Fantasy</td><td>1000000</td></tr><tr><td>Harry Potter</td><td>J.K. Rowling</td><td>Fantasy</td><td>900000</td></tr></table>'
  assert generate_html_table('Mystery')=='<table><tr><th>Title</th><th>Author</th><th>Genre</th><th>Sales</th></tr><tr><td>The Girl with the Dragon Tattoo</td><td>Stieg Larsson</td><td>Mystery</td><td>800000</td></tr><tr><td>Gone Girl</td><td>Gillian Flynn</td><td>Mystery</td><td>700000</td></tr></table>'
  assert generate_html_table('Romance')==''
output: def generate_html_table(genre):
      import sqlite3
  
      # connect to the database
      conn = sqlite3.connect('books.db')
      c = conn.cursor()
  
      # retrieve the data
      c.execute('''SELECT title, author, genre, 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>Genre</th><th>Sales</th></tr>'
  
      for result in results:
          title = result[0]
          author = result[1]
          genre = result[2]
          sales = result[3]
  
          html += f'<tr><td>{title}</td><td>{author}</td><td>{genre}</td><td>{sales}</td></tr>'
  
      html += '</table>'
  
      # close the database connection
      conn.close()
  
      return html