Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Introducing Lists Using Lists Continental

It seems my code is reading the first letter of the second word of a string. Tips on how to only read the first word?TIA

Not quite sure how to code to only read the first letter in the entire string

continents = [
    'South America',
    'North America',
# Your code here
for continent in continents:
    print("* " + continent)
if continents[0].lower() == "a":
    print("* ", continents)

1 Answer

Jason Anders
Jason Anders
Treehouse Moderator 145,740 Points

HI Ashley Chenn

You are on the right track, but the if statement needs to be inside the for loop. With each iteration of the loop, you want to be checking if the continent starts with an "A" and then print out only those. So, your for loop is correct and your if statement is correct (with one exception). You just need to move the if statement up into the for loop and then adjust the name of the variable in the if statement to check the right thing (continent instead of continents). Watch the indentations when you move it. It should look something like this:

for continent in continents:
    if <statement goes here>:
        <block of code for if statement here>

Nice work so far! :) :dizzy: