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

Amit Ramjee
Amit Ramjee
702 Points

How to print a list of items with only start with a specific letter?

Hi, I need to print continents that only start with 'A' below. I wrote the code below but for some reason treehouse is not accepting that as the correct answer even though the output print Asia, Africa, Antarctica, and Australia. Is my code written incorrectly?

Continents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ]

My code here

for continent in continents: if continent.startswith("A"): print (continent)

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]

for continent in continents:
    if continent.startswith("A"):
        print (continent)
# Your code here

1 Answer

Cheo R
Cheo R
37,150 Points

You're close. You're missing the extra part '* ' in front of each continent. May also want to remove the space between the word print and the left parenthesis.