HackerRank Python - Group(), Groups() & Groupdict()
group()
A group() expression returns one or more subgroups of the match.
groups()
A groups() expression returns a tuple containing all the subgroups of the match.
groupdict()
A groupdict() expression returns a dictionary containing all the named subgroups of the match, keyed by the subgroup name.
- # Enter your code here. Read input from STDIN. Print output to STDOUT
-
- import re
-
- m = re.search(r'([a-zA-Z0-9])\1', input().strip())
- print(m.group(1) if m else -1)