My understanding of the Range function in python is that:
- Range(beginning point, end point, amount to index by)
When the "amount to index by" is negative, you are basically going backwards, from the end towards the front.
My question is then:
- When going in reverse, does the value at position -end point- not get evaluated?
For example, if I want to reverse a string "a,b,c" (I know you can just do string[::-1], but that's not the point here)
string = 'a,b,c'
strlist = list(string.split(","))
empty_list = []
for i in range((len(strlist)-1),-1,-1):
print(strlist[i])
#this gets me "cba"
However when I change the end point from "-1" to "0" in the for loop, only "cb" gets printed:
string = 'a,b,c'
strlist = list(string.split(","))
empty_list = []
for i in range((len(strlist)-1),0,-1):
print(strlist[i])
#this only gets me "cb"
Thanks for your time :)