Jun-23-2022, 03:16 PM
Hi, trying to understand these arguments to this split command which I can't find documented. They may not be related to the split command.
Adding [1::2] to the end of the split. In my example it appears to omit the first and last '[]'s of my string. What exactly is this code, what documentation should I look at to understand it?
[ "word1" "word2" "word3" "word4" ]
--
['[ ', 'word1', ' ', 'word2', ' ', 'word3', ' ', 'word4', ' ]']
--
['word1', 'word2', 'word3', 'word4']
>
Thanks so much.
Adding [1::2] to the end of the split. In my example it appears to omit the first and last '[]'s of my string. What exactly is this code, what documentation should I look at to understand it?
mystring = '[ "word1" "word2" "word3" "word4" ]' print (mystring) result = mystring.split('"') result2 = mystring.split('"') [1::2] print ("--") print (result) print ("--") print (result2)OUPUT:
[ "word1" "word2" "word3" "word4" ]
--
['[ ', 'word1', ' ', 'word2', ' ', 'word3', ' ', 'word4', ' ]']
--
['word1', 'word2', 'word3', 'word4']
>
Thanks so much.