Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split Arguments ?
#2
You're correct, this doesn't have anything to do with split() itself. split() returns a list. List and other sequences support "slicing". Documentation about it can be see at Sequence Operations. It has the start, stop, and stride values separated by colons.

The start value of 1 says to return the element from index 1 of the list (skipping index 0), the lack of a stop value says to continue until the end, and the stride value of 2 says to return every second object.

>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9][1::2]
[1, 3, 5, 7, 9]
ndc85430 likes this post
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 710 Oct-23-2023, 03:59 PM
Last Post: deanhystad
  Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) Adelton 2 3,948 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