Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Introducing Lists Using Lists Continental

Roberto Quintero
Roberto Quintero
9,046 Points

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 67,464 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 67,464 Points

"Simple" code solution answers are to be discouraged.