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 trialHolly Bancroft
5,162 PointsHow did you solve the question "I'd like you to now only print continents that begin with the letter "A"."?
I am trying to figure out how to only list the continents that begin with "A". Could someone show me how they solved this?
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
for continent in continents:
print("* " + continent)
1 Answer
KRIS NIKOLAISEN
54,971 PointsThere is a hint: Remember that you can access characters in a string by index. For your code you would use continent[0]
to access the first character of continent
(the index starts at 0).
Then use an if statement and compare this to "A" and if they match print your bulleted list item.