Yeah. `join` has forever been backwards to me in Python and I still sometimes get it wrong the first time out.
Comprehensions, though -- they are perfection. :-)
Comprehensions, though -- they are perfection. :-)
That would make the mapping between a comprehension and the equivalent loop much clearer, especially once you use nested loops and/or conditionals.
For example, to flatten a list of lists `l = [[1, 2], [3], [4, 5, 6]]`:
[item for sublist in l for item in sublist]
vs [for sublist in l: for item in sublist: item]