Python‎ > ‎str‎ > ‎

str.split()


Definition
Return  with the rest of words after split(value).

Syntax
str.split(sep=None, maxsplit=-1) -> list of strings

Parameters
str=string

Examples
 >>> "Python Lake".split()
['Python', 'Lake']
>>> "Python".split("P")
['', 'ython']

The method convert the str to list and then append the item.
 >>> x="Python Lake"
>>> str.split(x)
['Python', 'Lake']
>>> type(['Python', 'Lake'])
<class 'list'>
>>> x.split()
['Python', 'Lake']
>>> z=x.split()
>>> z.append("Research Centre")
>>> z
['Python', 'Lake', 'Research Centre']

str.split().__ne__[list]
The return as following:
 >>> x=str.split("Python Lake")
>>> x
['Python', 'Lake']
>>> y=["Python", "Lake"]
>>> x==y
True
>>> x.__eq__(y)
True
>>> str.split("Python Lake").__ne__(["Python", "Lake"])
False
>>> 

slice()
Similar function:
 >>> a="I want to share some secrets with you."
>>> a[3:22]
'ant to share some s'
>>> 

Comments