Monday, 17 June 2019

Python: Grammatically correct human readable string from list (with Oxford comma)

I want a grammatically correct human-readable string representation of a list. For example, the list ['A', 2, None, 'B,B', 'C,C,C'] should return the string A, 2, None, B,B, and C,C,C. This contrived example is somewhat necessary. Note that the Oxford comma is relevant for this question.

I tried ', '.join(seq) but this doesn't produce the expected result for the aforementioned example.

Note the preexisting similar questions:



from Python: Grammatically correct human readable string from list (with Oxford comma)

No comments:

Post a Comment