Files
pyfa/gui/utils/listFormatter.py
2017-06-12 16:12:45 -04:00

10 lines
281 B
Python

def formatList(words):
"""Transforms ("a", "b", "c") into "a, b and c" string"""
if not words:
return ""
if len(words) == 1:
return words[0]
last = words[-1:][0]
beginning = ", ".join(words[:-1])
return "{0} and {1}".format(beginning, last)