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 2
HTML Parser - Part 2
Sort by
recency
|
142 Discussions
|
Please Login in order to post a comment
from html.parser import HTMLParser
class MyHTMLParser(HTMLParser): def handle_comment(self, data: str) -> None: if not len(data.splitlines()) == 1: print('>>> Multi-line Comment') for line in data.splitlines(): print(line) else: print('>>> Single-line Comment') print(data)
html = "" for i in range(int(input())): html += input().rstrip() html += '\n'
parser = MyHTMLParser() parser.feed(html) parser.close()
Sample Input
4 IE9-specific content
Welcome to HackerRank IE9-specific content