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

I am getting the right output, and only added one line of code. I can't make it any better. What am I doing wrong?

I am getting the right output, and only added one line of code. I can't make it any better. What am I doing wrong?

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
for continent in continents:
    if continent[0] == "A":
        print(continent)

1 Answer

Mark Sebeck
MOD
Mark Sebeck
Treehouse Moderator 38,004 Points

Hi Darnell. You are really close! You have the correct continents but they ask for a bulleted list. Try using string concatenation to add a "* " in front of the continent in your print.

Christopher Buckhout
seal-mask
.a{fill-rule:evenodd;}techdegree
Christopher Buckhout
Python Development Techdegree Student 786 Points

Thanks, Mark. I was running into the same issue and solved the coding challenge, but can you or someone explain why the [0] is required to pull each country starting with "A"? Thanks in advance.

Mark Sebeck
Mark Sebeck
Treehouse Moderator 38,004 Points

Hi Christopher. You're welcome. continent[0] represents the first position (remember arrays start at index 0) in the string array. So the IF statement checks if the first letter is equal to 'A'

The first time through the FOR loop continent will equal 'Asia' and continent[0] will equal 'A' and continent[1] will equal 's' and so on. Hope this helps.