4. String concatenation
Avoid writing extra control flow just to concatenate strings. In the first approach, you need extra logic to place commas correctly. In the second, join expresses the intent directly.
str.join also makes it clear that the separator belongs to the whole operation, not to any one element. That reduces fiddly edge-case logic around leading or trailing delimiters.
4.1. Don’t do this
1names = ['john', 'jane', 'jeremy', 'janice', 'joyce', 'jonathan']
2
3s = ''
4for i, name in enumerate(names):
5 s += name
6 if i < len(names) - 1:
7 s += ', '
4.2. Do this
1names = ['john', 'jane', 'jeremy', 'janice', 'joyce', 'jonathan']
2
3s = ', '.join(names)