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

  • Home
  • SEARCH
  • 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 8747857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:25:37+00:00 2026-06-13T12:25:37+00:00

Repeated slicing works on tuples and lists just fine: >>> tuple = (nav, yad)

  • 0

Repeated slicing works on tuples and lists just fine:

>>> tuple = ("nav", "yad")
>>> tuple[0]
'nav'
>>> tuple[0][0]
'n'

But with strings:

>>> name="university"
>>> name[0]
'u'

The weird thing here is, when I try repeated slicing over string name variable,
there is nothing at name[0][0] or name[0][-1], so why does it show "u"?

>>> name[0][0]
'u'
>>> name[0][-1]
'u'

And if something is at name[0][0] then why not on other indexes?

>>> name[0][1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: string index out of range
  • 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-13T12:25:38+00:00Added an answer on June 13, 2026 at 12:25 pm

    String is a sequence. String of one character is still a sequence with one element. So with a string you can do name[0][0][0][0]... and it will work fine. Same with index -1, that returns last element of a sequence:

    >>> name[0][0]
    'u'
    >>> name[0][0][-1]
    'u'
    >>> name[0][0][-1][-1]
    'u'
    

    name[0][1] obviously fails because there is only one element in the string name[0].

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

Sidebar

Related Questions

it will be just like repeated question on first look but it is not
This seems like a repeated question but i'm not able to get my answer.
I know this is repeated question on Stack. But in my case the URL
Maybe is a often repeated question here, but i can't find anything similar with
i want to remove repeated record's from results but distinct don't do this for
I have a grid with repeated columns with same style but different names the
How to pass by-name repeated parameters in Scala? The following code fails to work:
I need to count repeated rows but only show them in results if at
I'm sorry if is a repeated question, but i having trouble with PHP. I'm
I have a repeated class of .fancybox contained within image maps. <map name=Map1 id=Map1>

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.