[Tutor] class method problem
David Hutto
smokefloat at gmail.com
Sat Sep 25 21:03:40 CEST 2010
This returns a if "a" in, or -1 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
return -1
test = zoeken()
test.woord = "tamara"
stop = len(test.woord)
test2 = test.find(test.woord, "a", 1,stop)
print test2
David
More information about the Tutor
mailing list