MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / formatList

Function formatList

gui/utils/listFormatter.py:1–9  ·  view source on GitHub ↗

Transforms ("a", "b", "c") into "a, b and c" string

(words)

Source from the content-addressed store, hash-verified

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

Callers 1

__getDataMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected