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 trialDarnell Glenn
1,435 PointsI 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 = [
'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
Treehouse Moderator 38,304 PointsHi 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
Python Development Techdegree Student 786 PointsChristopher Buckhout
Python Development Techdegree Student 786 PointsThanks, 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
Treehouse Moderator 38,304 PointsMark Sebeck
Treehouse Moderator 38,304 PointsHi 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.