what is a split function in python?

0 votes
why do we use a split function?
Apr 11 in Python by Waseem
• 4,470 points
33 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 by rajesh
• 1,210 points

Related Questions In Python

+1 vote
3 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
121 views
+1 vote
1 answer

What is the function for Factorial in Python

Easiest way: math.factorial(x) (available in 2.6 and ...READ MORE

answered Aug 21, 2018 in Python by Priyaj
• 56,940 points

edited Aug 21, 2018 by Omkar 160 views
0 votes
1 answer

What is the meaning of “int(a[::-1])” in Python?

Assumming a is a string. The Slice ...READ MORE

answered Aug 27, 2018 in Python by Priyaj
• 56,940 points
84 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 348 views
+4 votes
6 answers
0 votes
3 answers
+4 votes
7 answers