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 which is the 5th element
Posting to the forum is only allowed for members with active accounts.
Please sign in or sign up to post.