=====Problem Statement=====
You are given a valid XML document, and you have to print the maximum level of nesting in it. Take the depth of the root as 0.

=====Input Format=====
The first line contains N, the number of lines in the XML document.
The next N lines follow containing the XML document.

=====Output Format=====
Output a single line, the integer value of the maximum level of nesting in the XML document.

Difficulty: introductory

Starter code:

import xml.etree.ElementTree as etree

maxdepth = 0
def depth(elem, level):
    global maxdepth
    # your code goes here

if __name__ == '__main__':
    n = int(input())
    xml = ""
    for i in range(n):
        xml =  xml + input() + "\n"
    tree = etree.ElementTree(etree.fromstring(xml))
    depth(tree.getroot(), -1)
    print(maxdepth)

Solutions:
# Enter your code here. Read input from STDIN. Print output to STDOUT
xml_str=""
n=int(input())
for i in range(0,n):
    tmp_str=input()
    xml_str=xml_str+tmp_str
    
import xml.etree.ElementTree as etree
tree = etree.ElementTree(etree.fromstring(xml_str))
root=tree.getroot()
ar=[]
def cnt_node(node):
    return max( [0] + [cnt_node(child)+1 for child in node])
cnt=cnt_node(root)
print(cnt)


maxdepth = 0
def depth(elem, level):
    #print(elem)
    if level == -1:
        level = 0
    nonlocal maxdepth
    if level > maxdepth:
        maxdepth = level
    for el in elem:
        depth(el, level+1)