Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Collections (Retired) Slices sillyCase

No idea how to "name three parts of slice syntax"

Hi - I know how to finish the sillycase() function but I have no idea about the quiz - how do I answer that question? I am not sure about the relevancy of that question also from a learning standpoint. is it [number:number:number]?

9 Answers

I found it easier to understand if you just picture writing a loop in python

for x in range(2, 30, 3):
  print(x)

2 = start at 2 30 = stop before 30 3 = increment by 3 as we go from 2-30

Hey Kenneth Love, I have a question, though your answer worked, isn't the order supposed to be start:step:stop?

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Nope. You name where you want to start, then where you want to stop, then how many steps to take each time. Start, stop, step.

it should be start:stop:step

I kept messing up because I thought the last one was stride!

Way to reference the documentation!

I can only think of [lowerbound:upperbound:stride] as a way of defining what goes into the gaps - in the documentation it has:

proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" [stride] ] lower_bound ::= expression upper_bound ::= expression stride ::= expression

So what goes into the first 2 gaps which both start with "st"?

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

It's in the last paragraph of the section that I linked you to. Start, stop, and step.

name = 'beven'
print(name[:]) # prints the string "beven"
print(name[:2]) # from start at index to 2
print(name[::-1]) # reverses the string prints 'neveb'

remember to mark best if it was useful

Hi,

The question mentions that each section begins with "st" - that was my question - no idea what to insert apart from "string" in the blanks!

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

We talk about it several times in the videos and it's in the documentation for slices, too.

yeah! I got it thanks

Eh had the right terms just messed up the stop, step order.