What's the quickest/cleanest way to remove the first word of a string? I know I can use split and then iterate on the array to get my string. But I'm pretty sure it's not the nicest way to do it.
split
Ps: I'm quite new to python and I don't know every trick.
Thanks in advance for your help.
I think the best way is to split, but limit it to only one split by providing maxsplit parameter:
maxsplit
>>> s = 'word1 word2 word3' >>> s.split(' ', 1) ['word1', 'word2 word3'] >>> s.split(' ', 1)[1] 'word2 word3'
2.1m questions
2.1m answers
60 comments
57.0k users