Sort by

recency

|

142 Discussions

|

  • + 0 comments
    from html.parser import HTMLParser
    class MyHTMLParser(HTMLParser):
        def handle_comment(self, data):
            if  '\n' in data:
                print(">>> Multi-line Comment") 
            else:
                print(">>> Single-line Comment")
            print(data)
        def handle_data(self, data):
            if data.strip():
                print(">>> Data")
                print(data)  
    html = ""       
    for i in range(int(input())):
        html += input().rstrip()
        html += '\n'
    parser = MyHTMLParser()
    parser.feed(html)
    parser.close()
    
  • + 0 comments

    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)

    def handle_data(self, data: str) -> None:
        if not data == '\n':
            print('>>> Data')
            for line in data.splitlines():
                print(line)
    

    html = "" for i in range(int(input())): html += input().rstrip() html += '\n'

    parser = MyHTMLParser() parser.feed(html) parser.close()

  • + 0 comments

    Sample Input

    4 IE9-specific content

    Welcome to HackerRank IE9-specific content
  • + 0 comments
    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)
        
        def handle_data(self, data: str) -> None:
            if not data == '\n':
                print('>>> Data')
                for line in data.splitlines():
                    print(line)
        
      
    html = ""
    for i in range(int(input())):
        html += input().rstrip()
        html += '\n'
        
    parser = MyHTMLParser()
    parser.feed(html)
    parser.close()
    
  • + 0 comments
    class MyHTMLParser(HTMLParser):
        def handle_comment(self, data):
            if '\n' in data:
                print(">>> Multi-line Comment")
            else:
                print(">>> Single-line Comment")
            print(data)
        def handle_data(self, data):
            if x := data.rstrip():
                print(">>> Data")
                print(x)