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 trialDavid Sanchez
623 PointsLists Indexing - Printing certain words beginning with a specific letter
Please help with the solving the programming challenge. I'm trying to print the continents that begin with the letter A only.
I've already reviewed the section on lists multiple times and I don't believe the instructor covers this.
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
for continent in continents:
print("*", continent)
2 Answers
Vikas Choudhary
Courses Plus Student 9,836 PointsYou have to check that first letter of each continent is "A" or not. If it is then only you have to print it
Solution
for continent in continents:
if continent[0] == "A":
print("*", continent)
Josh Keenan
20,315 PointsIt has been covered, you just need to add together a few things you have learned for this challenge.
You need to access the first letter of each string, and IF it is 'A', then you want to print it.
Hope this helps.
David Sanchez
623 PointsDavid Sanchez
623 PointsThank you. This worked.