anonymous
  • anonymous
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.
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
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
anonymous
  • anonymous
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.
anonymous
  • anonymous
I share your pain: I really want things to actually make sense rather than just knowing how to make stuff work.

Looking for something else?

Not the answer you are looking for? Search for more explanations.