python drop the first word 1

python drop the first word

>>> s = 'word1 word2 word3'
>>> s.split(' ', 1)
['word1', 'word2 word3']
>>> s.split(' ', 1)[1]
'word2 word3'

Here is what the above code is Doing:
1. We are splitting the string s into a list of strings, using the space character as the delimiter.
2. We are telling the split() function to only split the string once.
3. We are taking the second element of the list that split() returns.

Similar Posts