You are viewing a single comment's thread. Return to all comments →
I was stuck during 10 minutes because I got "None" value in my output... Because this is the return value of the parse function if nothing...
Nevermind, I finally fix this problem.
Here the code :
from html.parser import HTMLParser N = int(input()) class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): print("Start :", tag) if attrs: for element in attrs: attribute_name = element[0] attribute_value = element[1] print(f"-> {attribute_name} > {attribute_value}") def handle_endtag(self, tag): print("End :", tag) def handle_startendtag(self, tag, attrs): print("Empty :", tag) if attrs: for element in attrs: attribute_name = element[0] attribute_value = element[1] print(f"-> {attribute_name} > {attribute_value}") parser = MyHTMLParser() for _ in range(N): current_line = input() if parser.feed(current_line): print(parser.feed(current_line))
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 →
I was stuck during 10 minutes because I got "None" value in my output... Because this is the return value of the parse function if nothing...
Nevermind, I finally fix this problem.
Here the code :