We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
fromhtml.parserimportHTMLParser# create a subclass and override the handler methodsclassMyHTMLParser(HTMLParser):defhandle_starttag(self,tag,attrs):print("Start :",tag)fori,jinattrs:print(f"-> {i} > {j}")defhandle_endtag(self,tag):print("End :",tag)defhandle_startendtag(self,tag,attrs):print("Empty :",tag)fori,jinattrs:print(f"-> {i} > {j}")# instantiate the parser and fed it some HTMLparser=MyHTMLParser()for_inrange(int(input())):parser.feed(input())
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
HTML Parser - Part 1
You are viewing a single comment's thread. Return to all comments →