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.
Group(), Groups() & Groupdict()
Group(), Groups() & Groupdict()
Sort by
recency
|
259 Discussions
|
Please Login in order to post a comment
from itertools import groupby import re
S = input() X = re.findall(r'[A-Za-z0-9]', S) alphanumeric = ''.join(X) groups = [char for char, group in groupby(alphanumeric) if len(list(group))>1] if len(groups)>0: print(groups[0]) else: print('-1')
import re match = re.search(r'([A-Za-z0-9])\1', input()) print(match.group(1) if match else -1)
import re
s = input()
digits = re.findall(r'(.)\1+', s)
for char in digits: if char.isalnum(): print(char) break
else: print(-1)
Here is HackerRank Group(), Groups() & Groupdict() in Python solution - https://programmingoneonone.com/hackerrank-group-groups-groupdict-solution-in-python.html