[Tutor] why does this fail
Greg Bair
gregbair at gmail.com
Wed Aug 25 20:18:28 CEST 2010
On 08/25/2010 06:00 AM, Roelof Wobben wrote:
>
> 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 ?
>
I'm assuming what you really want is :
if letter in strng:
print "true"
else:
print "false"
<snip>
More information about the Tutor
mailing list