Skip to content Skip to sidebar Skip to footer

How Does .join Work In Python?

I want to display each row of a SQL query result on a webpage. I found some code, but I don't understand what this line does. u''.join([u'{0}'.format(row.combination) fo

Solution 1:

Best to run a python shell and test it, such as:

>>> "x".join (["a", "b", "c"])
'axbxc'
>>> "abc".join (["M"])
'M'

The "x" was used as the thing in between the values in the iterable. Next time "abc" was used in between, except there was only one value, so there was no in between needed.

Then refer to the docs as per CoryKramer comment.

Post a Comment for "How Does .join Work In Python?"