Doubt in the "Change it up" exercise


Here's my code for the exercise:

fruits = ['banana', 'apple', 'orange', 'tomato', 'pear', 'grape']

print 'You have...'
for f in fruits:
    if f[0] == 'a' or 'e' or 'i' or 'o' or 'u':
        print 'An', f
        print 'A', f
    print 'A fine selection of fruits!'

The output on the console is the following:
You have...
An banana
An apple
An orange
An tomato
An pear
An grape
A fine selection of fruits!

I don't understand why the fruits which don't begin with a vowel get printed with the article "an" in front of them, whereas my code suggests that only fruits which begin with a vowel should have "an" in front of them in the output.

Any sort of help is appreciated. Thanks.


Please post a link to this exercise. We're just as lost as you without it. Thank you.


I don't think that's needed but here you go:


I do. Thank you for posting it.


Your expression is evaluated like this:

(f[0] == 'a') or 'e' or 'i' or 'o' or 'u'

What do you think this evaluates to?

False or 'e'

And what happens if you convert 'e' to bool?

What happens if you do this?

if 'e':
    print 'hello'