Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

algotruneman Group Title

I'm trying to get a handle on string slicing. Thanks for any help. I thought -1 referenced the last character of a string. See my Gist for the code snip. https://gist.github.com/4328274 Further reading shows that print group[start: ] is the right format. The question still remains in my mind, though.

  • one year ago
  • one year ago

  • This Question is Closed
  1. exchaoordo Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    I can't give you the deep theory, but if you try this, you'll see what's going on: x = "012345" print x[:-1] ##up to but not including last character print x[-1]##print last character print x[0:] ##up to and including last character

    • one year ago
  2. algotruneman Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks, exchaoordo. I guess my problem is that the logic of -1 being both a reference to the last character of the string AND the penultimate (last - 1) character is confusing. But, I'll live with it and move on.

    • one year ago
  3. exchaoordo Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    I share your pain: I really want things to actually make sense rather than just knowing how to make stuff work.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.