EDIT: I should be more clear. I really want to SKIP characters/letters, so not only solve the task of getting the first and last character to show. Even if I can do that by now. [::5] seems to work though.
I'm trying to slice a single word in python, so I'm given the first and the last letter. According to everything I read my code should be
word_ = "carrot"
letter = word_[0:6:4]
Spaces included for readability.
word = "c a r r o t" # 0 1 2 3 4 5 # _ # _ # _ # _ # _
The first character is indexed at 0, the last at 5.
So you'll take 5 steps to reach the last starting from the first. But if you're going to include the last character in the slice, the stop parameter of the slice has to be one place ahead; since the stop index is usually not included.
So your slice is
[0:6:5] -> [start:stop:step]. There are sleeker ways to get the first and last index viz.
[::len(s)-1] but you can start with the former.
4 is not how many character you want to skip, but the number of steps required to reach the next character of your choice. And t will be located at 5 not 6