String index beginner Python

Could someone help me to figure out why the start index 7 and ending index 26 is True? Dont we count here from 0 ,then we wouldn`t get ‘7’ and ‘26’ indexes. A bit confused(


# start parameter: 7
# "programming is easy to learn." string is searched
result = text.endswith('learn.', 7)
print(result)

# Both start and end is provided
# start: 7, end: 26
# "programming is easy" string is searched

result = text.endswith('is', 7, 26)
# Returns False
print(result)

result = text.endswith('easy', 7, 26)
# returns True
print(result)  <p>```
1 Like

To be honest the last result return False to me^^

1 Like

Yes, there is one False there. It is an example from programmiz website and here is the output:

```True
     False
      True```

https://www.programiz.com/python-programming/methods/string/endswith(the second example)

1 Like

Maybe it’s because the text variable value is actually "Python programming is easy to learn." (example 2 in Programmiz).

If we start from the index 7, endswith will scan from index 7 to the end and that would be “programming is easy to learn.”

If we start from the index 7 to index 26, endswith will scan from index 7 to index 26 and that would be “programming is easy”.