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

Rocco Soucie
Rocco Soucie
1,018 Points

Having Trouble on "Iteration" Quiz on Learning Lists Coarse.

I am still new to Python, and I have no idea on how to target the first letter of each object in a list. Do I have it look for the "len" of each item and have it correspond to "first_letter"? Any help would be appreciated.

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

1 Answer

Steven Parker
Steven Parker
231,248 Points

You have the right basic idea, but the index should be applied directly to the string variable :point_right: continent[0]

Also, the symbol for comparison is "==", just a single "=" is an assignment operator.

Rocco Soucie
Rocco Soucie
1,018 Points

So should I have my code like this?:

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

This doesn't work, and I still don't know how to look at the first letter of each item in my list. Do I have to use the "len" differently or at all?

Steven Parker
Steven Parker
231,248 Points

You won't need "len" at all for this challenge.