Fix bugf in index -- last char would not be checked.

This commit is contained in:
Guido van Rossum 1990-12-26 15:39:06 +00:00
parent a4ddbd885e
commit 66a07c07a5
2 changed files with 2 additions and 2 deletions

View File

@ -83,7 +83,7 @@ def splitfields(s, sep):
index_error = 'substring not found in string.index'
def index(s, sub):
n = len(sub)
for i in range(len(s) - n):
for i in range(len(s) + 1 - n):
if sub = s[i:i+n]: return i
raise index_error, (s, sub)

View File

@ -83,7 +83,7 @@ def splitfields(s, sep):
index_error = 'substring not found in string.index'
def index(s, sub):
n = len(sub)
for i in range(len(s) - n):
for i in range(len(s) + 1 - n):
if sub = s[i:i+n]: return i
raise index_error, (s, sub)