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.
HTML Parser - Part 1
HTML Parser - Part 1
Sort by
recency
|
179 Discussions
|
Please Login in order to post a comment
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 :
I need to follow number of different spaces when printing the output. ~~~
from html.parser import HTMLParser
class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): print("Start :", tag) for attr in attrs: print("->", attr[0], ">", attr[1])
parser = MyHTMLParser() n = int(input()) for _ in range(n): s = input()
~~~
Here is HackerRank HTML Parser - Part 1 in Python solution - https://programmingoneonone.com/hackerrank-html-parser-part-1-solution-in-python.html