Python String join() method is a string method and returns a string in which the elements of the sequence have been joined by the str separator.
Python's join()
method is a powerful tool for working with strings. It is a string method that is used to concatenate a list of strings with a specified delimiter. The join()
method takes an iterable (such as a list or a tuple) of strings as its argument and returns a new string that is created by concatenating all the elements in the iterable separated by the delimiter.
The basic syntax of the join()
method is as follows:
string_name.join(iterable)
Here, string_name
is the string that will be used as the delimiter to join the elements in the iterable. The iterable
is the list of strings that will be joined.
For example, let's say we have a list of strings that we want to join together with a comma as the delimiter:
fruits = ['apple', 'banana', 'orange'] result = ', '.join(fruits) print(result)
Output:
apple, banana, orange
In the above example, we first create a list of fruits, and then use the join()
method to concatenate them with a comma delimiter. The resulting string is then printed to the console.
The join()
method is a very useful tool for working with strings, and can be used in a wide variety of contexts, such as generating CSV files, building SQL queries, or creating HTML templates.
Australia
UK
UAE
Singapore
Canada
New
Zealand
Malaysia
USA
India
South
Africa
Ireland
Saudi
Arab
Qatar
Kuwait
Hongkong
Copyright 2016-2023 www.programmingshark.com - All Rights Reserved.
Disclaimer : Any type of help and guidance service given by us is just for reference purpose. We never ask any of our clients to submit our solution guide as it is, anywhere.