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.
# Enter your code here. Read input from STDIN. Print output to STDOUTimportrerecord={}for_inrange(int(input())):elements=re.findall(r'(<[\w].*?>)',input())forelementinelements:tag=re.findall(r'<([\w]+)',element)attributes=re.findall(r'\s([a-z]+)=',element)iftag[0]notinrecord:record[tag[0]]=set()record[tag[0]].update(set(attributes))results=[]forkey,valueinrecord.items():results.append([key,list(value)])results=sorted(results,key=lambdax:x[0])forresultinresults:result[1].sort()print(f"{result[0]}:{','.join(result[1])}")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Detect HTML Attributes
You are viewing a single comment's thread. Return to all comments →
Easy Python3 Solution: