Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string slicing
#1
Hi, i just want to ask what is the default begining point and the ending point of a slice with negative step like this

X='123456789'
print(X[::-1])
I try to find what exactly begining point and ending point of the slice:

>>> x='123456789'
>>> x[0:len(x):-1]
''
>>> x[len(x):0:-1]
'98765432'    (not include '1')
>>> x[len(x):-1:-1]
''
Can anyone just tell me what is the starting point and ending point when we slice with default like this x[::-1]
Reply


Messages In This Thread
string slicing - by Uchikago - Jun-28-2019, 03:01 AM
RE: string slicing - by Gribouillis - Jun-28-2019, 04:22 AM
RE: string slicing - by perfringo - Jun-28-2019, 06:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python3 string slicing Luchano55 4 534 Feb-17-2024, 09:40 AM
Last Post: Pedroski55
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,387 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  String slicing and loop iteration divyansh 9 4,619 Jun-07-2020, 10:29 PM
Last Post: divyansh
  String slicing divyansh 6 3,284 May-31-2020, 06:15 AM
Last Post: pyzyx3qwerty
  string slicing help oli_action 2 2,150 Mar-22-2020, 09:57 AM
Last Post: oli_action
  Accepting strings as arguments when slicing a string? (Ziyad Yehia on Udemy) Drone4four 4 3,722 Aug-23-2019, 07:59 PM
Last Post: Drone4four
  string slicing default value Uchikago 1 2,787 Jul-01-2019, 11:19 AM
Last Post: perfringo
  String slicing in python from reverse ift38375 1 2,359 Apr-29-2019, 06:58 AM
Last Post: perfringo
  String Slicing in List Comphrensions Patroclus72790 1 2,228 Mar-21-2019, 09:33 PM
Last Post: nilamo
  String slicing problem Ollew 4 2,745 Sep-08-2018, 08:07 PM
Last Post: Ollew

Forum Jump:

User Panel Messages

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