String split and join in Python
Here we explain String split and join in Python.
Python provides us with various inbuilt functions, two of which are split and join.
String Split in Python
Split is a function in which we can split a string.
Example: of split() function
String = "Example on Split function" String = String.split(" ") print String ['Example', 'on', 'Split', 'function']
Here we have taken a variable name as String which stores a string Example on Split function then calling the function split(). It splits the content of the String variable and stores in the String variable.
String Join in Python
Join is a function in which can be used to join various words or sentences separated by any keyword.
Example of join() function
String="Apple Orange Mango" String = ",".join(String) print String ['Apple','Orange','Mango']
Here also we have taken a variable name String which stores Apple Orange Mango and we have called join() function which separates each word by a comma and then prints it.
- Encryption and Decryption of String using Python
- Track the occurrences of a character in a string in Python