find depth

# Enter your code here. Read input from STDIN. Print output to STDOUT no_lines = input() xml = ' ' for line in range(0, no_lines): xml = xml + raw_input() import xml.etree.ElementTree as etree tree = etree.ElementTree(etree.fromstring(xml)) root = tree.getroot() def depth(root): return max([0] + [depth(child) + 1 for child in root]) print depth(root)

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.