Sobes.tech
Middle

Write a function that takes a string and returns the first unique character (the character that appears exactly once).

sobes.tech AI

Answer from AI

python def first_unique_char(s: str) -> str: from collections import Counter counts = Counter(s) for ch in s: if counts[ch] == 1: return ch return '' # если уникальных символов нет

Пример использования

print(first_unique_char('swiss')) # вывод: w