Stedents Question
Geert-Jan Van den Bogaerde
gvdbogae at vub.ac.be
Fri Mar 1 19:16:57 EST 2002
On Sat, 2002-03-02 at 01:12, Geert-Jan Van den Bogaerde wrote:
> On Sat, 2002-03-02 at 00:45, Tony K wrote:
> > The question below is a tutorial question that stumps me. Any suggestions
> > would be appreciated.
> > Tony
> >
> > Write a Python function findABBC which takes a single string as parameter
> > and returns all substrings thereof which match the regexp pattern ab+c. You
> > are NOT allowed to use the re module.
> >
>
> Haven't used regexps in a while, but I believe that just means:
>
> def findABBC(str):
> return str == "a" + "b" * len(str[1:-1]) + "c"
>
And as I press send I spot an error in my code, it should be:
def findABBC(str):
return len(str) > 2 and str == "a" + "b" * len(str[1:-1]) + "c"
as we need at least one b
Geert-Jan
More information about the Python-list
mailing list