mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-11 01:04:10 +02:00
Fix omitting end / beginning in ranges (#2649)
This commit is contained in:
@@ -208,9 +208,9 @@ li[4] # Raises an IndexError
|
|||||||
# You can look at ranges with slice syntax.
|
# You can look at ranges with slice syntax.
|
||||||
# (It's a closed/open range for you mathy types.)
|
# (It's a closed/open range for you mathy types.)
|
||||||
li[1:3] # => [2, 4]
|
li[1:3] # => [2, 4]
|
||||||
# Omit the beginning
|
|
||||||
li[2:] # => [4, 3]
|
|
||||||
# Omit the end
|
# Omit the end
|
||||||
|
li[2:] # => [4, 3]
|
||||||
|
# Omit the beginning
|
||||||
li[:3] # => [1, 2, 4]
|
li[:3] # => [1, 2, 4]
|
||||||
# Select every second entry
|
# Select every second entry
|
||||||
li[::2] # =>[1, 4]
|
li[::2] # =>[1, 4]
|
||||||
|
Reference in New Issue
Block a user