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

How to iterate through each item to check if only the first word begins with 'A'?

I am unsure how to iterate through each items to check if the first word begins with an 'A'. The challenge implies to use index, however I don't know how that is used to iterate through an entire list. Here is what I have to far...: for continent in continents: if continent #begins with an A:
print( '* ' + continent)

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
for continent in continents:
    if continent #begins with an A:  
        print( '* ' + continent)

1 Answer

I am not a Python Student but I got your Answer. what you should also do is to remove the last comma in your array.

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

for continent in continents: if continent.startswith('A'):
print( '* ' + continent)