In this HackerRank Detect HTML Tags, Attributes and Attribut Values problem solution You are given an HTML code snippet of N lines. Your task is to detect and print all the HTML tags, attributes and attribute values.

HackerRank Detect HTML Tags, Attributes and Attribute Values in python problem solution

 HackerRank Detect HTML Tags, Attributes and Attribute Values in python problem solution

from html.parser import HTMLParser

num = int(input())

class MyHTMLParser(HTMLParser):
    def handle_starttag(self, tag, attrs):
        print(tag)
        for x,y in attrs:
          print("->", x, ">", y)

parser = MyHTMLParser()
for x in range(num):
  parser.feed(input())