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 trialAlberto Serafini
1,211 Pointsindex
I can't solve the second part of the challenge when it is asking to print the continents with the initial "A" . Can anybody please help? Thank you!
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
# Your code here
for continent in continents:
print("* " + continent)
5 Answers
Steven Parker
231,275 PointsYou need to add an "if" statement to control when the "print" is done. Give it a conditional expression comparing the first character of "continent" to the letter "A".
You can isolate a character in a string using an index (value in brackets).
Alberto Serafini
1,211 PointsSo sorry Steven I'm sure your answer is very clear but i can't figure out the solution.
Steven Parker
231,275 PointsTry adding an "if" statement using the hints given. If you still have trouble, show the new version.
Stephen Williams
3,372 PointsI'm confused on why this works.. in the if statement you put ( if continent[0] == "A": ) so wouldn't the computer only check and print the location of continent[0] which is Asia instead of printing out the other continents? I hope this made sense.
Alberto Serafini
1,211 PointsSo Steven I've been trying lots of things maybe the less embarrassing version i wrote is: for continent in continents : if continent[0] == "A" print("* " + continent) And obviously is wrong.
Alberto Serafini
1,211 PointsWow ! Thank you so much Steven, finally it's working. I appreciate so much the way you helped me out!
Alberto Serafini
1,211 PointsAnd Thank you Steven for the Markdown formatting link!
Steven Parker
231,275 PointsSteven Parker
231,275 PointsIt's impossible to check the indentation without Markdown formatting (as I used below), but if your indentation is already correct it looks like you're only missing the colon at the end of the "if" line: