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.

Python Introducing Lists Using Lists Continental

Shavez Memon
seal-mask
.a{fill-rule:evenodd;}techdegree
Shavez Memon
Python Development Techdegree Student 2,449 Points

So what is the solution?

Hi, I'm using this code which is printing all the continents but how do I print just Asia and South America? Thanks a ton!

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here

for continent in continents:
    print('*' + continent) 

4 Answers

Steven Parker
Steven Parker
208,478 Points

You're almost there! You just need to add a space to prevent the 'bullet" from being against the name:

    print('* ' + continent) 

Task 1 is to print all continents. Task 2 is to print only those beginning with "A" (which would not include "South America" since it begins with "S")..

If you're working on task 2 you'll need to add an "if" statement that isolates the first letter and compares it with "A". But both tasks require the output to have a "bullet" and a space before the name.

Steven Parker
Steven Parker
208,478 Points

The task 2 "if" should test "continent" (singular) instead of the whole "continents" list.

And the "print" statement should be the same as for task 1 (with the "bullet" and space).

Shavez Memon
seal-mask
.a{fill-rule:evenodd;}techdegree
Shavez Memon
Python Development Techdegree Student 2,449 Points

Hey, thank you for clarifying. Also, I'm struggling with Task2. My code is below. Could you tell me what I can fix?

if continents[0] == 'A':

print (continents)
Steven Parker
Steven Parker
208,478 Points

I added a comment to my answer.

Shavez Memon
seal-mask
.a{fill-rule:evenodd;}techdegree
Shavez Memon
Python Development Techdegree Student 2,449 Points

Thanks for responding. I think I did as you told for Task2 and I still get an error:

if continent[0] == 'A':

print('* ' + continent)
Steven Parker
Steven Parker
208,478 Points

Check your indentation, otherwise it looks fine.

And when posting code to the forum, use Markdown formatting to preserve the appearance.