This is a little better, it returns a if "a" in, or None if using "z":

class zoeken() :
        pass
        def __len__(self):
                return 0
        def __str__(self):
                return test2
        def find(self, strng, ch, start, stop):
                index = start
                while index < len(strng) and index < stop:
                        if strng[index] == ch:
                                return ch
                        index += 1

test = zoeken()
test.woord = raw_input('Enter string of letters to search: ' )
stop = len(test.woord)
search = raw_input('Enter character to find: ')
#print 'search =' ,search
test2 = test.find(test.woord, search, 1,stop)
print test2

Of course, there are other ways to accomplish this.

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

Reply via email to