Python String join() MethodPython join() method is used to concat a string with iterable object. It returns a new string which is the concatenation of the strings in iterable. It throws an exception TypeError if iterable contains any non-string value. It allows various iterables like: List, Tuple, String etc. SignatureParametersiterable : iterable object like: List, Tuple, String etc. ReturnIt returns a new string or an exception TypeError if iterable contains any non-string value. Let's see some examples of join() method to understand it's functionalities. Python String join() Method Example 1A simple example which implements join() method with the List iterable, see the example below. Output: 1:2:3 Python String join() Method Example 2A list iterable join with empty string and produce a new string, see the example below Output: Javatpoint Python String join() Method 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# Python String join() Method 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
|
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week