Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8689081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:32:54+00:00 2026-06-12T23:32:54+00:00

>>>helloworld[::1] ‘helloworld’ >>>helloworld[::-1] ‘dlrowolleh’ according to the syntax str[start:end:step] . the start is by

  • 0
>>>"helloworld"[::1]
'helloworld'

>>>"helloworld"[::-1]
'dlrowolleh'

according to the syntax str[start:end:step].
the start is by default 0 in both the cases.
in first case the string is printed from index value 0.
but in second case the string is printed from index value -1.

and my question is why is string printed from -1 in the later case and why it is so ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:32:56+00:00Added an answer on June 12, 2026 at 11:32 pm

    According to the documentation (emphasis added):

    The slice of s from i to j with step k is defined as the sequence of items with index x = i + n*k such that 0 <= n < (j-i)/k. In other words, the indices are i, i+k, i+2*k, i+3*k and so on, stopping when j is reached (but never including j). If i or j is greater than len(s), use len(s). If i or j are omitted or None, they become “end” values (which end depends on the sign of k). Note, k cannot be zero. If k is None, it is treated like 1.

    This means that if the slice stride is positive, an ommited slice start is the start of the sequence and an omitted slice end is the end of the sequence. If the slice stride is negative, it is the opposite. You can see this if you fill in one of the two values:

    >>> '0123456'[:3]
    '012'
    >>> '0123456'[:3:-1]
    '654'
    >>> '0123456'[3:]
    '3456'
    >>> '0123456'[3::-1]
    '3210'
    

    One way to think of this is to visualize the sequence as a loop, where the start and end are the same point. When you omit one end of the slice, you are just specifying to use this “both-ends-point” as an endpoint, but not which direction to go from there. It is the stride sign that tells you which way to go, and this determines whether you are treating the “both-ends-point” as the beginning or the end of the sequence.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

. . . as in this example: helloworld.rb:1: syntax error, unexpected '=', expecting $end
I am having string like: NSString *str = @Helloworld.123 456; I need to get
$str = 'HelloWorld'; $sub = substr($str, 3, 5); echo $sub; // prints loWor I
There is the start of official Jasmin HelloWorld example. .class public NoJad.j .super java/lang/Object
I am trying the helloworld example for PhoneGap. http://www.phonegap.com/start/#android When I start the android
I realize my first helloworld 3days ago, and now I wana go futher. I
class HelloWorld(object): def say_it(self): return 'Hello I am Hello World' def i_call_hello_world(hw_obj): print 'here...
var Helloworld = { onLoad: function() { // initialization code this.initialized = true; },
When compiling my wxWidget HelloWorld application, I am getting the following errors: Warning 1
Can someone provide a HelloWorld demo ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.