I looked up the word zoeken -- it means find in English.

I looked up the chapter and exercise in the online text "How to think
like a computer scientist"

Its a good tutorial.

I think the OP seems to get confused on basic concepts.

Here is my stab at the exercise:

#!/usr/bin/env python

"""This exercise is to take the find function, alter it so that it can
specify an end point for the search.  It is problem 2 at the end of this
chapter:
http://openbookproject.net/thinkcs/python/english2e/ch15.html

The author notes that end should default to len(str), but it can't since
default parameters are initialized when the function is defined and not
when it is invoked.
"""

# this is from the author's text
def find(str, ch, start=0):
    index = start
    while index < len(str):
        if str[index] == ch:
            return index
        index = index + 1
    return -1

# this I believe is the concept the author was looking to get the
reader to understand

def find2(str, ch, start=0, end = None):
    if end == None:
        end = len(str)
    index = start
    while index < end:
        if str[index] == ch:
            return index
        index = index + 1
    return -1




-- 
Joel Goldstick
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to