input: Write a function to generate an XML document using Python which includes the provided list of items as sub elements under a root 'data' element. If the list of items is empty, the function should still create a valid XML file with an empty 'data' element.
  assert generate_xml(["Item1", "Item2", "Item3"]) == '<data><item>Item1</item><item>Item2</item><item>Item3</item></data>'
  assert generate_xml([]) == '<data></data>'
  assert generate_xml(["ItemA"]) == '<data><item>ItemA</item></data>'
output: def generate_xml(items):
      from xml.etree.ElementTree import Element, tostring
      data = Element('data')
      for item in items:
          item_element = Element('item')
          item_element.text = item
          data.append(item_element)
      return tostring(data, encoding='unicode', method='xml').replace('/>', '>')