Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Sequences Sequence Operations Creating Slices

Help! I can't seem to understand this

I need help with this question. can someone explain the answer to me?

student_gpas = [4.0, 2.3, 3.5, 3.7, 3.9, 2.8, 1.5, 4.0]

The challenge wants you to provide characters from 3rd element to the 5th element of the student_gpas list, and python starts numbering from 0 so to slice the list you would:

sliced_gpas = student_gpas[2:5]

Slices work just like using the range function, the first number is the starting point of the slice and the second number is the stopping point but unlike the first number the second number is not included in the range so counting stops before the second number and in our case it would stop at student_gpas[4] which is the 5th element