On Mar 21, 2013 1:35 PM, "leonardo selmi" <[email protected]> wrote: > > hi all, > > i wrote the following code: > > def find(word, letter): > index = 0 > while index < len(word): > if word[index] == letter: > return index > index = index + 1 > return -1 >
More efficient:
def find(word, letter):
return word.find(letter)
Or even:
find = str.find
Cheers,
Ian
-- http://mail.python.org/mailman/listinfo/python-list
