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

Chris Bogues
seal-mask
.a{fill-rule:evenodd;}techdegree
Chris Bogues
Python Web Development Techdegree Student 537 Points

How can I print only the letter A

Hello - I'm a little confused on how I can select certain continents. If I do 'continents[0] ', I get the first letter. How can I select the ones with the letter A?

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
for continent in continents:
    print("* " + continent[0])

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

What if you use continent[0] as an if statement condition, then print whole name?

Post back if you need more help. Good luck!!!

Edin Gunic
Edin Gunic
1,664 Points

I struggled with this one a bit but reading Chris's answer was a lot of help. Here is what worked for me:

continents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ]

for continent in continents: if continent[0] == "A": print("* " + continent)