Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introducing Lists Using Lists Continental

The preview pane is showing no errors, but the answer is still wrong

for continent in continents: print("*", continent)

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
for continent in continents: 
    print("*", continent)

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,457 Points

Task 2 will involve using an if statement. Have you scrolled down to see all of the test preview results?

Your current code yields:

Task #2
F
======================================================================
FAIL: test_filtered (__main__.TestFilteringExecution)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "", line 14, in test_filtered
AssertionError: 'South America' unexpectedly found in '* Asia\n* South America\n* North America\n* Africa\n* Europe\n* Antarctica\n* Australia' : Whoops! I found a country that didn't start with A in your output

Hi Roberto!

This passes task 1:

continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
for continent in continents:
    print("*", continent)

This passes task 2:

continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
for continent in continents:
    if continent[0] == 'A':
        print("*", continent)

I hope that helps.

Stay safe and happy coding!

Chris Freeman
Chris Freeman
Treehouse Moderator 68,457 Points

"Simple" code solution answers are to be discouraged.