[Tutor] class method problem
David Hutto
smokefloat at gmail.com
Sat Sep 25 21:18:43 CEST 2010
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
More information about the Tutor
mailing list