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

Raul Cisneros
Raul Cisneros
7,319 Points

Selecting all list items that begin with the letter "A".

I have spent enough time trying to figure this out. I am not looking for a hint, I am looking for the solution. Can anyone help?

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

2 Answers

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

1- index(), It is just return the first value in sq match to its arg.So , you don't need it here. 2-you need to use (:) by the end of your for loop.

Good luck!!

Raul Cisneros
Raul Cisneros
7,319 Points

Im sure to most people this was an easy one, but being new to python I couldn't figure it out. Thank you so much! I definitely wont forget this one!

You are welcome. We all here to learn :) Good luck!!