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.
Lists/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)
Chris FreemanTreehouse Moderator 68,239 Points
Hey 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 or the method
continent.startswith() where the argument is the string you hope to match, as in,
Post back if you need more hints. Good luck!!
That’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!