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 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?

slices.py
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