# 18 change it up


#1



I've looked at the forum, I played with indentations, what am I missing please?


Oops, try again. It looks like your code is not executing its else statement.


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

print 'You have...'
for f in fruits:
    if f == 'tomato':
        print 'A tomato is not a fruit!' # (It actually is.)
        break
    elif f != 'tomato':
        print 'A', f
else:
    print 'A fine selection of fruits!'


#2

I believe we could just use else: here and not have a condition.


#3

it's funny how when it is posted elsewhere, it becomes clearer.
I took out the break and it worked.:smiley_cat:


#4

That is not what we need to do, though. The break should stay. The trick is to change the conditional to something that is not a fruit (or more specifically, not in the list).

if f == 'potato':

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.