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
122 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,230 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
329 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
• 58,100 points

edited Aug 21, 2018 by Omkar 410 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
• 58,100 points
704 views
0 votes
2 answers
+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, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,992 views
0 votes
0 answers
+4 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,810 points
1,528 views
0 votes
4 answers

What is a Tuple in Python and how to use it?

Tuples  are a  Unchanging sequence of values, ...READ MORE

answered Jun 21, 2020 in Python by sahil
• 540 points
579 views
+4 votes
7 answers