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

Not sure how to print a specific item from a list based on the first letter.

I am stuck... I am trying to figure out how to print specific items from a list.

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

1 Answer

Dario Bahena
Dario Bahena
10,697 Points

You have to check for the letter that you want.

continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
## continents is a list
for continent in continents:
## here, continent is a single item in the list of continents. The first time it will be "Asia"
    if (continent[0] == "A"):
## Since continent is "Asia", check if the first letter is "A"
        print continent

Okay that makes sense! Thank you!