input: Write a function to construct an XML document using Python which contains a list of items. The function should take a list of strings as input and write the resulting XML tree to a file named 'data.xml'.
  import xml.etree.ElementTree as ET
  
  def create_xml_document(items):
      # creating the root element
      data = ET.Element('data')
      
      # loop over items
      for item in items:
          # creating sub elements
          item_element = ET.SubElement(data, 'item')
          
          # assign the value for the sub elements
          item_element.text = item
      
      # write the XML Tree
      tree = ET.ElementTree(data)
      tree.write('data.xml')
  
  assert create_xml_document(['Item1', 'Item2', 'Item3'])
  import xml.etree.ElementTree as ET
  tree = ET.parse('data.xml')
  root = tree.getroot()
  assert [item.text for item in root] == ['Item1', 'Item2', 'Item3']
  assert create_xml_document([])
  import xml.etree.ElementTree as ET
  tree = ET.parse('data.xml')
  root = tree.getroot()
  assert len(root) == 0
output: 
  def create_xml_document(items):
      data = ET.Element('data')
      for item in items:
          item_element = ET.SubElement(data, 'item')
          item_element.text = item
      tree = ET.ElementTree(data)
      tree.write('data.xml')
  