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 9022451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:30:49+00:00 2026-06-16T05:30:49+00:00

I have a string of variable length and I know the index position is

  • 0

I have a string of variable length and I know the index position is 25. As it’s variable in his length (>= 25), I need a way to locate the negative index of that same position for easier data manipulation.

Do you have any idea how this can be done?

  • 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-16T05:30:50+00:00Added an answer on June 16, 2026 at 5:30 am

    I’m not sure if this is what you’re after, but if you have the index of a string, the ‘negative’ index is just the negative of the length of the string minus the index:

    In [1]: import string
    
    In [2]: s = string.ascii_letters
    
    In [3]: s
    Out[3]: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    
    In [4]: s[25]
    Out[4]: 'z'
    
    In [5]: -(len(s)-25)
    Out[5]: -27
    
    In [6]: s[-(len(s)-25)]
    Out[6]: 'z'
    

    Or using the example from the comments:

    In [7]: s = range(1, 7)
    
    In [8]: s[4]
    Out[8]: 5
    
    In [9]: neg = -(len(s)-4) # Here you would replace 4 with your index
    
    In [10]: s[neg]
    Out[10]: 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that strings have variable length, therefore they need variable space in memory
I have strings like that; a-variable-part[] another-string[x] without knowing the length of each string
I have a string of a variable length and at the end of the
I have a variable length array of strings declared in javascript that contains Dungeons
I have javascript string variable with var sttr=We prefer questions that can be answered
I have read an article on Internet and know that the natural way of
I have a binary file with variable length record that looks about like this:
I have an algorithm that reads from the stdout into a string variable called
I know how to define a method with variable length argument: case class taxonomy(vocabularies:(String,Set[String])*)
Possible Duplicate: Split String into smaller Strings by length variable I have seen solutions

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.