A community for students. Sign up today!
Here's the question you clicked on:
 0 viewing
 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])
 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

davidbrenton
 one year ago
Best ResponseYou've already chosen the best response.0I 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 < (ji)/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.

bwCA
 one year ago
Best ResponseYou've already chosen the best response.0the info is also in the documentation
Ask your own question
Ask a QuestionFind 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
 Engagement 19 Mad Hatter
 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.