what is a split function in python

0 votes
why do we use a split function?
Apr 11, 2019 in Python by Waseem
• 4,540 points
1,933 views

1 answer to this question.

0 votes

use of split function in python 

At some point, you may need to break a large string down into smaller chunks, or strings. This is the opposite of concatenation which merges or combines strings into one.To do this, you use the split function in python. What it does is split or breakup a string and add the data to a string array using a defined separator.If no separator is defined when you call upon the function, white space will be used by default. In simpler terms, the separator is a defined character that will be placed between each variable.

example

x = ‘blue,red,green
x.split(“,”)
 
>>>[‘blue’, ‘red’, ‘green’]
 
>>> a,b,c = x.split(“,”)
 
>>> a
‘blue’
 
>>> b 
‘red’
 
>>> c
‘green’

answered Apr 22, 2019 by rajesh
• 1,270 points

Related Questions In Python

+1 vote
7 answers
0 votes
1 answer

What is the use of raw_input function in Python?

raw_input fuction is no longer available in ...READ MORE

answered May 2, 2018 in Python by aayushi
• 750 points
2,924 views