xor@tech.intersects.art ("Parker Higgins") wrote:
got some really great replies to this, and it's so fun to see different approaches to a pretty simple and common but not quite trivial problem. for those curious, i think i am going to go with:
def join_bylines(l):
return ', '.join(l[:-1]) + ', and ' + l[-1] if len(l) > 2 else ' and '.join(l)but some nice alternatives with generators, match statements, and even one with python's behavior of returning the first truth-y value in an and operation. neat!