input: Write a function to generate an XML document using Python which represents the given list of items. The function should create a root element named 'data' and for each item in the list, it should create a sub-element named 'item' and assign the item's name as its text content. Finally, the function should write the XML tree to a file named 'data.xml'.
  assert generate_xml(['Item1', 'Item2', 'Item3']) is None
  assert open('data.xml').read() == '<data><item>Item1</item><item>Item2</item><item>Item3</item></data>'
  assert generate_xml([]) is None
  assert open('data.xml').read() == '<data />'
  assert generate_xml(["ItemA", "ItemB"]) is None
  assert open('data.xml').read() == '<data><item>ItemA</item><item>ItemB</item></data>'
output: 
  def generate_xml(items):
      from xml.etree.ElementTree import Element, SubElement, ElementTree
      root = Element('data')
      for item in items:
          sub_elem = SubElement(root, 'item')
          sub_elem.text = item
      tree = ElementTree(root)
      tree.write('data.xml', encoding='unicode', method='xml')
  