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'd like you to now only print continents that begin with the letter "A".

I noticed there already is an answer to the question, however i still want to know why my code is wrong. It keeps skipping over the first value in continents(Asia)?

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

2 Answers

Rune Andreas Nielsen
Rune Andreas Nielsen
5,354 Points

Hi Olivier,

The reason that your code is not doing is expected is because you're checking for the lowercase 'a' instead of uppercase 'A'.

The underlying value of lowercase 'a' and uppercase 'A' is different therefore your conditional statement is not executing as you might expect it to. If you want to know more about why this is happening you can read into UNICODE and ASCII characters.

https://docs.python.org/3/howto/unicode.html

// Rune