3 ms·
He had me up until the part where he wrote an algorithm to specifically leave out the Oxford Comma. :) Kidding aside, this was a great read.
by sneak 15y ago
He had me up until the part where he wrote an algorithm to specifically leave out the Oxford Comma. :)
Kidding aside, this was a great read.
- Luyt 15y agoAs he remarks, he doesn't take in account the corner cases. Suprisingly, or maybe not, his concatenation statement is similar to what I regularly use: def commalist(f, endword="and"): "Concatenate a list of strings in the form of 'Red, Yellow, Green and Blue'." if len(f) == 0: return "" elif len(f) == 1: return f[0] else: return ", ".join(f[:-1]) + " " + endword + " " + f[-1]