#!/usr/local/bin/python2 import xml.etree.ElementTree as ET e = ET.fromstring('') print tuple(e).index(e[-1]) print len(e)