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 trialTinashe Steve Chipangura
1,000 Pointshow do i write the code please help
I'd like you to now only print continents that begin with the letter "A".
HINT: Remember that you can access characters in a string by index
Important: In each task of this code challenge, the code you write should be added to the code from the previous task.
continents.py
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
for continent in continents:
print("* " + continent)
β
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
for continent in continents:
print("* " + continent)
nakalkucing
12,964 PointsHi Tinashe Steve Chipangura! Am I correct that you need help with the second part of this challenge?
2 Answers
Caleb Newell
12,562 PointsOk! Thanks for the heads up. i will do better.
Caleb Newell
12,562 Pointsfor the second part you might want to try something like this:
for continent in continents:
if continent[0] == 'A':
print("* {}".format(continent))
Tinashe Steve Chipangura
1,000 Pointsthanks very much hey, it worked
Caleb Newell
12,562 PointsYour welcome. Glad to help :)
nakalkucing
12,964 PointsHey Caleb Newell! I'm glad to see you want to help, that's great. :) I just want to let you know, it is usually frowned on to just give the answer to the challenge without an explanation of why and how it works.
Happy coding!
Yamil PΓ©rez
Courses Plus Student 2,054 PointsYamil PΓ©rez
Courses Plus Student 2,054 Pointsfor continent in continents: print("* " + continent) Your code looks right. you should check he indentation