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 trialOmar Hamad
Courses Plus Student 697 PointsI do not understand this question: HINT: Reme
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
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']
# Your code here
if A in continent:
for continent in continents:
if A in continent:
print ("* " + continent)
4 Answers
angel moreta
2,912 Pointsyou are overthinking the challenge, delete both if statements, then indent the print function inside the loop.
angel moreta
2,912 Pointsfor task number two: for continent in continents: if 'A' in continent[0]: # you can also do this: 'A' == continent[0] print ("* " + continent)
**** remember the challenge says that you can access characters in a string by index****
Tonye Jack
Full Stack JavaScript Techdegree Student 12,469 PointsYou can use python str.startswith to find letters from the beginning of the string.
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']
for continent in continents:
if continent.startswith('A'):
print("* " + continent)
Kudakwashe Moyo
3,811 Pointsontinents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ]
Your code here
for continent in continents: print("*", continent)
for letters in continents: if letters[0] == "A": print("* " + letters)