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

Python Introducing Lists Using Lists Continental

Shavez Memon
seal-mask
.a{fill-rule:evenodd;}techdegree
Shavez Memon
Python Development Techdegree Student 2,452 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
231,248 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
231,248 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,452 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
231,248 Points

I added a comment to my answer.

Shavez Memon
seal-mask
.a{fill-rule:evenodd;}techdegree
Shavez Memon
Python Development Techdegree Student 2,452 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
231,248 Points

Check your indentation, otherwise it looks fine.

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