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

I am not able to print continents which start with letter "A"

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

Your code here

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

This is what I tried to do

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



for continent in continents:
    print("* " + continent)

3 Answers

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

this should work

Steven Tagawa
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Steven Tagawa
Python Development Techdegree Graduate 14,426 Points

Hi Vitthal,

You've almost got it! If continents were the single string 'Asia', then continents[0] would be the first character in the string, or 'A'. But continents is a list, so continents[0] is the first item in the list, or the whole word 'Asia'. So to find the first character in continents[0], you would write... ?

(Remember that because a string is like a list of characters, a list of strings is really just like a list of lists.)

Steven Tagawa
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Steven Tagawa
Python Development Techdegree Graduate 14,426 Points

Okay, so I went back and re-did this challenge, and it wouldn't work for me either for a quite a while. I finally figured out that you have to ignore the little message that says to add your new code after the existing code. Do NOT do that—delete the code from the first task that prints out the whole list, and make sure that the code you have above is the ONLY code there. That code WILL work. That seems that printing out the whole list again first is what's tripping up the testing routines.