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)
![Ajet Shabani](https://secure.gravatar.com/avatar/4da2727e4c765bb2380334f1e87f6330?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ajet Shabani
439 PointsI'd like you to now only print continents that begin with the letter "A". someone explain me this
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
for continent in continents:
print ('*', continent)
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsBy indexing with brackets, you can isolate the first character of a string. For example, the first letter of name would be name[0]. Then, it's a simple matter to compare it to what you are looking for.
![Asher Orr](https://uploads.teamtreehouse.com/production/profile-photos/11686423/micro_updated_headshot_2022.jpg)
Asher Orr
Python Development Techdegree Graduate 9,408 PointsHi Ajet!
In challenge task 1 of 2, you looped through each continent in the list "continents" and printed it next to a bullet point. Nice work!
For challenge task 2, the one you're asking about, you need to modify the code so that it prints out the continent ONLY if the first letter starts with A.
Your code needs a conditional statement to make this work. Conditional statements use the operators if, elif, and else.
Here's an example:
x = "Ajet"
if x == "Ajet":
print("The variable x stores the value 'Ajet'")
else:
print("The variable x does not store the value 'Ajet'")
If you ran this code, "The variable x stores the value 'Ajet'" would print to the console.
But if you changed x to "Asher", like this:
x = "Asher"
if x == "Ajet":
print("The variable x stores the value 'Ajet'")
else:
print("The variable x does not store the value 'Ajet'")
"The variable x does not store the value 'Ajet'" would print to the console.
To solve the challenge, you need to print the continent only if the first character is A. Remember that you can access characters in a string by index. Let me show you an example.
my_list = [
'one',
'two',
'three',
'four',
'five',
]
for number in my_list:
print(number[0])
The code above would print this to the console:
o
t
t
f
f
To solve the challenge, your code should incorporate both concepts (conditional statements and accessing characters in a string by index.)
I hope this helps! Let me know if you have additional questions.
![samsrose](https://uploads.teamtreehouse.com/production/profile-photos/11701337/micro_689659.jpg)
samsrose
3,691 PointsAfter seeing your comment, it seemed like a no-brainer. Thank you for clarifying this.