in Technology by
Explain split() and join() functions in Python?

1 Answer

0 votes
by
  • ou can use split() function to split a string based on a delimiter to a list of strings.
  • You can use join() function to join a list of strings based on a delimiter to give a single string.
string = "This is a string."
string_list = string.split(' ') #delimiter is ‘space’ character or ‘ ‘
print(string_list) #output: ['This', 'is', 'a', 'string.']
print(' '.join(string_list)) #output: This is a string.

Related questions

0 votes
    1. Name the term which is used to join two separate arrays into a single array. 2.How are the following ... ii) primitive type data Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    Is there any way to split the string if it contains an uppercase letter but not the first letter? For example, ... solution to it? Select the correct answer from above options...
asked Jan 8, 2022 in Education by JackTerrance
0 votes
    In a list with range(1,16) and I am trying to divide this list in some fixed numbe n . Let's assume n=7 ... uneven, How can I do that? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    I have an array of the shape (100000, 1) with each element in an array of type positive integer and not ... help would be appreciated. Select the correct answer from above options...
asked Jan 8, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: asynchronous python itertools chain multiple generators (2 answers) Closed 2 ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I am confused about the usage of string.join(list) instead of list.join(string), for instance see this code: ... reason behind this? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    How to join three sources using joiner? Explain though mapping flow....
asked Mar 28, 2021 by JackTerrance
0 votes
    Which of the following functions is a built-in function in python? a) factorial() b) print() c) seed() d) sqrt()...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    Apparently xrange is faster but I have no idea why it's faster (and no proof besides the anecdotal so far that it ... xrange(0, 20): Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    I've spent the past few hours reading around in here and elsewhere, as well as experimenting, but I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    Which of the following is also known as split testing?...
asked Apr 11, 2021 in Technology by JackTerrance
0 votes
    0 2 ['name:', 'Atlanta', 'GA:', 'Hartsfield-Jackson', 'Atlanta', 'International'] 35 ['name: ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I know this appears subjective and is likely to be closed but I'll ask anyway. When you use a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I know this appears subjective and is likely to be closed but I'll ask anyway. When you use a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I wish to divide pandas dataframe to 3 separate sets. I know by using train_test_split from sklearn.cross_validation, ... ? kindly help Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
...