seattlecitylight-mastodon-bot/posttext.py

12 lines
277 B
Python
Raw Permalink Normal View History

from collections.abc import Sequence
def list_to_sentence(list: Sequence[str]) -> str:
match len(list):
case 0:
return str()
case 1:
return list[0]
case _:
return " and ".join((", ".join(list[0:-1]), list[-1]))