Welcome to the Treehouse Community
Looking to learn something new?
Stuck on code challenge on python basics
Make a new variable, var_two, with "e" at index -2. Remember, negative indexes start at the right side of the iterable.
Can anyone provide the answer and explain it to me? Thank you!
Python has reverse index as well. For example:
string = "ABCDE" #inde: 0 1 2 3 4 #RevInd:-5-4-3-2-1 #So, #string = string[-1] #string = string[-2] #and so on...
It is to remember that forward index starts from 0 whereas backward index starts with -1.
Now lets talk about the question/task
we need variable that has 'e' at index -2.
var_two = "ef" var_two = "abcef"
are both examples that has 'e' at index -2
Hope this helps.