#Q1
#DataScience #Python #String
You can split up your string into separate substrings according to the presence of whitespace. This creates a list of strings, where a 'list' is simply a container for the strings. Lists are Python objects in thier own right and we will discuss further in the next time.
In the other way we can also combine a list of strings and create a single long text.
Q: what functions we use to separate and combine strings? Explain using examples.
Post your solution @pythonEthBot
#PreventCOVID19
#DataScience #Python #String
You can split up your string into separate substrings according to the presence of whitespace. This creates a list of strings, where a 'list' is simply a container for the strings. Lists are Python objects in thier own right and we will discuss further in the next time.
In the other way we can also combine a list of strings and create a single long text.
Q: what functions we use to separate and combine strings? Explain using examples.
Post your solution @pythonEthBot
#PreventCOVID19
#Solution for #Q1 by @oneyedking
split() function used to split string to substrings
Example :
Str = "coding with python"
Str.split(' ')
Result : "coding", "with", "python"
By @met_asploit
There are built in func
split and join
while split is used to separate a string and create a list , join is used to combine list and create a string
>>> a = ['a' , 'b' , 'c' , 'd']
>>>' '.join(a)
'a b c'
>>>b = 'hello how are you'
>>>b.split(' ')
['hello' , 'how' , 'are' , 'you']
split() function used to split string to substrings
Example :
Str = "coding with python"
Str.split(' ')
Result : "coding", "with", "python"
By @met_asploit
There are built in func
split and join
while split is used to separate a string and create a list , join is used to combine list and create a string
>>> a = ['a' , 'b' , 'c' , 'd']
>>>' '.join(a)
'a b c'
>>>b = 'hello how are you'
>>>b.split(' ')
['hello' , 'how' , 'are' , 'you']