I am learning python,and I am confused about how the index of an array woks in python. Following is my code
test_var = "hello how are you"
print(test_var[-1], ",", test_var.find('t'))
The output of this program is.
u , -1
Now I understand that negative indexing is allowed in python unlike java and it most probably works in cyclic manner so that -1
indicates the last character.
But when it comes to find
method and it does not match any character 't'
it again gives -1
. So does it imply that -1
is like the null value in python?
And it does not mean that find
has returned the position of the last character?
Is it just me or would it be less confusing if an unsuccessful find
would return None
?