Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split Arguments ?
#1
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?


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.
Reply


Messages In This Thread
Split Arguments ? - by jesse68 - Jun-23-2022, 03:16 PM
RE: Split Arguments ? - by bowlofred - Jun-23-2022, 04:18 PM
RE: Split Arguments ? - by jesse68 - Jun-24-2022, 03:27 PM
RE: Split Arguments ? - by Larz60+ - Jun-24-2022, 07:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Class takes no arguments bily071 2 674 Oct-23-2023, 03:59 PM
Last Post: deanhystad
  Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) Adelton 2 3,911 Mar-02-2017, 10:23 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020