Group(), Groups() & Groupdict()

Sort by

recency

|

267 Discussions

|

  • + 0 comments

    import re

    S = input()

    fount_it = re.search(r'([a-zA-Z0-9])\1+', S)

    if fount_it: print(fount_it.group(1)) else: print(-1)

  • + 0 comments

    S = input() found_it= False for i in range(len(S)-1): j=S[i] if j.isalnum() is True and S[i+1]==j: found_it = True print(j) break if found_it is False: print(-1)

  • + 0 comments

    Using regex

    import re
    task = input()
    
    cases = set(re.findall(r"([a-zA-Z0-9])", task))
    cases = "".join(cases)
    
    pattern = f"([{cases}])(?=\\1+)"
    
    matches = re.search(pattern, task)
    
    print(matches.group(1) if matches and matches.group(1) else "-1")
    
  • + 0 comments
    s = input()
    for i in range(1,len(s)):
        if s[i].isalnum() and s[i] == s[i-1]:
            print(s[i])
            break
    else:
        print(-1)
    
  • + 0 comments
    import re
    if result := re.search(r'([a-zA-Z0-9])\1',input()):
        print(result.group(1))
    else:
        print(-1)