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

Accessing list using index

I'm trying to print out only continents that begin with the letter A but don't know what i am doing wrong

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




# Your code here

2 Answers

your whole second for loop is unneeded. all you need is to go above your first print statement and add an if statement that uses the startswith() method

something like this

for continent in continents:
    if continent.startswith("A"):
        print("* "+ continent)
Marzoog AlGhazwi
Marzoog AlGhazwi
15,796 Points

you don't need a second for loop, instead make some changes to the first loop

for continent in continents:
    if continent[0] == "A":    
        print('* ', continent)