[Tutor] why does this fail
Roelof Wobben
rwobben at hotmail.com
Wed Aug 25 12:00:33 CEST 2010
Hello,
I have this programm :
def remove_letter(letter, strng):
"""
>>> remove_letter('a', 'apple')
'pple'
>>> remove_letter('a', 'banana')
'bnn'
>>> remove_letter('z', 'banana')
'banana'
>>> remove_letter('i', 'Mississippi')
'Msssspp'
"""
antwoord=""
for letter in strng:
print letter, strng
if letter in strng:
print "false"
else:
print "true"
return antwoord
x=remove_letter('a', 'apple')
print x
But now everything is false even a in apple.
What is here wrong ?
Roelof
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100825/635c6834/attachment.html>
More information about the Tutor
mailing list