October 2004
Intermediate to advanced
336 pages
6h 27m
English
This function finds a substring within a string. It returns a tuple with two elements:
The first element is the part of the outer string before the substring.
The second element is the rest of the outer string (beginning with the substring).
If the substring is not found, the first element of the tuple is the entire original string and the second element is an empty string.
Note
The standard Python string library has a function, find(), that does essentially the same operation. (It returns the index of the first occurrence of the substring, not a tuple.) This book doesn't use that here.
1. def findSubstring ( outerString, ...Read now
Unlock full access