Logo

Programming-Idioms

History of Idiom 53 > diff from v41 to v42

Edit summary for version 42 by programming-idioms.org:
New Python implementation by user [programming-idioms.org]

Version 41

2016-11-30, 21:15:43

Version 42

2016-12-22, 09:26:47

Idiom #53 Join a list of strings

Concatenate elements of string list x joined by the separator ", " to create a single string y.

Illustration

Idiom #53 Join a list of strings

Concatenate elements of string list x joined by the separator ", " to create a single string y.

Illustration
Code
y = ', '.join(str(v) for v in x)
Comments bubble
This works even if some elements in x are not strings.
Doc URL
https://docs.python.org/3/library/stdtypes.html#str.join