In this source code example, we will demonstrate how to use the Python String join() method to concatenate strings in an iterable into one string.
Python
Python String
Basically, we use the join() method to concatenate multiple strings in an iterable into one string.
The following example uses the string join() method to concatenate a tuple of strings without a separator:The following example uses the string join() method with the comma separator (,):
Python String join() method
The string join() method returns a string which is the concatenation of strings in an iterable such as a tuple, a list, a dictionary, and a set.
The following shows the syntax of the join() method:
The following shows the syntax of the join() method:
str.join(iterable)
Python String join() method examples
name = ('source', 'code', 'examples')
fullName = ''.join(name)
print(fullName)
Output:
sourcecodeexamples
name = ('source', 'code', 'examples')
fullName = ','.join(name)
print(fullName)
Output:
source,code,examples
Related Python String Examples
- Python string literals
- Python string length example
- Python String join() method example
- Python string split() method example
- Python String index() method example
- Python string find() method example
- Python string startswith() method example
- Python string endswith() method example
- Python String lower() method example
- Python String upper() method example
- Python string title() method example
- Python string capitalize() method example
- Python string islower() method example
- Python string istitle() method example
- Python string isupper() method example
- Python string swapcase() method example
- Python string strip() method example
- Python string replace() method example
- Python string isdigit() method example
- Python string isdecimal() method example
- Python string isnumeric() method example
- Python string isalpha() method example
- Python string isalnum() method example
Comments
Post a Comment