Skip to content

Instantly share code, notes, and snippets.

View samsonlarsson's full-sized avatar
🌌

Samson Larsson samsonlarsson

🌌
View GitHub Profile
from collections.abc import Iterable, Callable
from typing import TypeVar, Optional
T = TypeVar('T')
def one(iterable: Iterable[T], condition: Callable[[T], bool] = bool) -> bool:
"""
Determines whether exactly one item in the iterable satisfies the given condition.