.join() in Python


Could anyone give a clear explanation of the use of .join() in Python.


Hello @blue_rhinoceros,

The join tag in python is a string method. So, it takes a string, and it between its parentheses, it takes a list to be joined. The usage of it is as follows.

list_1 = ["a", "b", "c", "d"]
join_list = "-".join(list_1)
join_another_list = " ".join(list_1)

print join_list # prints a-b-c
print join_another_list # prints a b c

Hope you understand the function of .join() now!


Thank you very much. The Flash is awesome and I watch it (too bad Season 2 is finished).


Haha, I know, right! Anyways, keep coding hard :laughing:! If you feel my response is satisfactory, please mark it as the solution, so that others can know it is finished... Thanks!