Python String join() MethodLast Updated : 31 Dec 2025 The join() strategy is an underlying technique in Python that has a place with the string class. Concatenating or joining elements from an iterable, like a list, tuple, or string, into a single string is what this method does. Syntax of Python String join() MethodThe join() technique takes the accompanying syntax. Example: Using String Join() MethodLet's look at an example to illustrate the usage of the join() method: Output: Hello World Python Programming Explanation: The string "," which only contains one space character, is the basis for the call to the join() method in this example. There are four components in the iterable lis. The string "Hello World Python Programming" is created by concatenating the elements of lis with the separator "" using the join() method. The string is then output as a string. It allows various iterables like: List, Tuple, String etc. Signature:It has the following signature: Parameters
ReturnIt returns a new string or an exception TypeError if iterable contains any non-string value. Different Examples for Python String join() MethodLet's see some examples of join() method to understand it's functionalities. Example 1A simple example which implements join() method with the List iterable, see the example below. Output: 1:2:3 Example 2A list iterable join with empty string and produce a new string, see the example below Output: Javatpoint Example 3An example of join() method with Set iterable. Set contains unordered elements and produce different output each times. See the example below. Output: Java->Python->C# Example 4In case of dictionary, this method join keys only. Make sure keys are string, otherwise it throws an exception. Output: key1&key2 Next TopicPython Strings |
We request you to subscribe our newsletter for upcoming updates.