Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

davidbrenton

  • one year ago

I don't understand the logic behind the use of two or more colons (Example Pset7 problem 19: result of str4[1:9:2])

  • This Question is Open
  1. davidbrenton
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I found the logic behind this problem on stackoverflow.com since my textbook hasn't yet arrived. I copied the logic from there and pasted below: s[i:j:k] slice of s from i to j with step k 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.

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

    the info is also in the documentation

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

    Search OpenStudy
    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

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.