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

annika kuntz
annika kuntz
2,034 Points

How to only get items starting with "A" , printed out of a list

I was thinking about a while or if statement but i cannot figure out how to write a case to only print out the continents starting with the letter "A".

thanks in advance :D

continents = [
    'South America',
    'North America',

for i in continents :
    for str("A") in i :
        print("* " + i)

still need help here?

1 Answer

The loop will cycle through each word in the list. Check if the first letter of the current word is an A. If it is, print it.

Let me know if this helps here