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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Katrine AMS Guirguis](https://uploads.teamtreehouse.com/production/profile-photos/11562272/micro_FC8F9720-2930-463D-BB8E-7FD25025D40A.jpg)
Katrine AMS Guirguis
2,587 PointsLists/Continents Python challenge: I need help with task 2
I’m confused about the code for task two....
continents = [
'*Asia',
'*South America',
'*North America',
'*Africa',
'*Europe',
'*Antarctica',
'*Australia',
]
print("continents:")
for continent in continents:
print("*" + continent)
3 Answers
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,425 PointsHey Katrine Guirguis, After Task 1, the for-loop and the print statement output every continent in continents
. For Task 2, the challenges is to only print the continents that begin with an A.
One strategy is to use a put the print statement in a code block under a conditional statement, such as an if
statement. The condition would be to verify the first character of the continent name begins with an "A".
As a refresher, you can access the first character of a string continent
using an index, as in, continent[0]
or the method continent.startswith()
where the argument is the string you hope to match, as in, startswith(“A”)
Post back if you need more hints. Good luck!!
![Katrine AMS Guirguis](https://uploads.teamtreehouse.com/production/profile-photos/11562272/micro_FC8F9720-2930-463D-BB8E-7FD25025D40A.jpg)
Katrine AMS Guirguis
2,587 PointsThat’s what I thought of, but I kinda need help with the if statement... Also, would we have to use the index string as the challenge says? Thanks!
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,425 PointsI’ve expanded my answer above to show more explicit examples on how to access the first character of the variable string continent
using an index and with the existing method startswith()
![Katrine AMS Guirguis](https://uploads.teamtreehouse.com/production/profile-photos/11562272/micro_FC8F9720-2930-463D-BB8E-7FD25025D40A.jpg)
Katrine AMS Guirguis
2,587 PointsThank you!!
Chris Freeman
Treehouse Moderator 68,425 PointsChris Freeman
Treehouse Moderator 68,425 PointsSorry, there are two other errors in the code.
continents
list. These need removalLuis Rivas
Courses Plus Student 23,047 PointsLuis Rivas
Courses Plus Student 23,047 PointsThank you, Chris!