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)
![Han Htoo Aung](https://secure.gravatar.com/avatar/32ce75e4171d5e45a52b18e9a77be95e?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Han Htoo Aung
1,473 PointsI'd like you to now only print continents that begin with the letter "A".
Please help me with this. Thank you. still stuck here!!!
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
# Your code here
print(continents)
for continent in continents:
print (" * " + continent[0,3,5,6])
3 Answers
![Sumiya Malik](https://secure.gravatar.com/avatar/1e62ecb3a2ad0d27196589175b6193d8?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Sumiya Malik
3,976 PointsSo we know we can access the string using index. the for loop will take all these continents one by one and iterate it. When the variable(continent) will have first continent(Asia), it will go inside the loop and check if the continent name starts from "A". if it dose it will print the name of the continent else it will go back to the for loop and go on with the second continent and again check if that continent starts with "A". for loop will take all the continents one by one and if statement will check if the continent starts with letter "A". if continent[0]=="A" will check the first alphabet in the continent and prints if that starts with letter "A".
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
# Your code here
for continent in continents:
if continent[0]=="A":
print(continent)
Let me know if you understood!
![Han Htoo Aung](https://secure.gravatar.com/avatar/32ce75e4171d5e45a52b18e9a77be95e?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Han Htoo Aung
1,473 PointsThank you
![Joseph Yhu](https://uploads.teamtreehouse.com/production/profile-photos/10742228/micro_121009504_105928134617925_5772733173913238661_n.jpg)
Joseph Yhu
PHP Development Techdegree Graduate 48,637 PointsUse an if statement and use the fact that you can access the first element of a string just like a list, i.e. indexing by 0 str[0]
for example. Also remove this line: print(continents)
since it's not needed.
![Sumiya Malik](https://secure.gravatar.com/avatar/1e62ecb3a2ad0d27196589175b6193d8?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Sumiya Malik
3,976 PointsLet me know if you understood.
Han Htoo Aung
1,473 PointsHan Htoo Aung
1,473 PointsI don't get it yet loll