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

I'm trying to get the continents that start with the Letter "A". It says there is an AssertionError.

Ive tried this on my computer and it works fine but I try it here and it doesn't. It wants me to do this by string indexing.

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

for con in continents:
    if 'A' in con:
        print(con)

2 Answers

Steven Parker
Steven Parker
231,269 Points

The membership operator ("in") will tell if the letter occurs anywhere in the string, which is not what you want here. For example there is an "A" in "South America" but that's not a name that begins with "A".

You don't have to use indexing, but it's one convenient way of checking just the first letter of a name.

Also the sample output shown in the challenge comments indicate that each name should be preceded by an asterisk and a space.

Thank you. It works now