Reputation: 1
I believe my professor taught us a way to begin parsing through a string at the first occurrence of a blank space (or any character for that matter) but I seem to have forgotten it. I'm trying to slice through a sentence starting at the first letter of the second word. Can anyone give me some help?
The code would receive a string similar to that shown below:
'Donald Springman 50 98.0\nKenneth Clarke 52 97.3\nRon Martin 51 95.5'
What I need to do is sort the strings by the given last names. So what I am hoping for is a way to simply bypass the first word in the string, and start parsing at the first space, therefore starting at the second word.
Upvotes: 0
Views: 904
Reputation: 1077
If I understand what you mean is:
string = 'word1 word2 word3'
print(string[string.find(' ') + 1:])
outputs:
'word2 word3'
Upvotes: 1