I am just starting out on the slicing strings Cut Me A Slice exercise and slicing is already confusing to me.
Here is the link to the exercise:
I ran the solution on this exercise and I am confused by how the system generated solution is correct.
The question is: Create a variable called
temp_password by creating a slice out of the third through sixth letters of his
What I understand from this question is to include the characters starting from index 3 and ending at index 7 (to include the sixth letter).
My code would look like this:
The system solution looks like this:
last_name="Villanueva" temp_password = last_name[2:6]
Which generates the result ‘llan’.
I’m confused why if the question is asking for a slice that includes the 3rd character would it start with the index 2? If it is asking to include up to the sixth character, wouldn’t the last index need to be 7 so that it includes the 6th character?