1.

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

Answer»
  • You 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.


Discussion

No Comment Found