As you guessed, 0
is considered as "falsey". The documentation lists other "falsey" values.
print bool(0)
# False
But you can check like this
def test(self, index=None):
if index is not None:
print(str(index))
else:
print("Index not found")
This program makes sure that the input is not None
and if it is not, it is user provided (irrespective of its Truthiness).