You are viewing a single comment's thread. Return to all comments →
This problem has epic problem with \r, \n, rstrip() etc.
So, I am posting my Python 3 solution here. Hope someone code a better solution and share with us. :)
from html.parser import HTMLParser class CustomHTMLParser(HTMLParser): def handle_comment(self, data): number_of_line = len(data.split('\n')) if number_of_line>1: print('>>> Multi-line Comment') else: print('>>> Single-line Comment') if data.strip(): print(data) def handle_data(self, data): if data.strip(): print(">>> Data") print(data) parser = CustomHTMLParser() n = int(input()) html_string = '' for i in range(n): html_string += input().rstrip()+'\n' parser.feed(html_string) parser.close()
Seems like cookies are disabled on this browser, please enable them to open this website
HTML Parser - Part 2
You are viewing a single comment's thread. Return to all comments →
This problem has epic problem with \r, \n, rstrip() etc.
So, I am posting my Python 3 solution here. Hope someone code a better solution and share with us. :)