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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Ashley Chenn](https://secure.gravatar.com/avatar/7e79ac104092ca008ba174f6d6fe67a2?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ashley Chenn
1,903 PointsIt 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 = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
# Your code here
for continent in continents:
print("* " + continent)
if continents[0].lower() == "a":
print("* ", continents)
1 Answer
![Jason Anders](https://uploads.teamtreehouse.com/production/profile-photos/3512822/micro_Jason_s-Pic.jpg)
Jason Anders
Treehouse Moderator 145,859 PointsHI 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! :)