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 trialJorge Grajeda
Python Development Techdegree Graduate 8,186 PointsI figured out how to do the first challenge but am now stuck on the second one
I reviewed the video but couldn't understand how to get the continents that start with A
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
print(continents[0],[3],[5],[6])
print("continents:")
for continent in continents:
print("* " + continent)
1 Answer
Jennifer Nordell
Treehouse TeacherHi there, Jorge Grajeda ! Yup you got the first part done just fine. Nice job! Just like lists can be accessed by index, so can strings!
If I had the following:
greeting = "Hello World"
print(greeting[1])
It would print out e
because "e" is the second letter or the index of 1. Yes, it starts at an index of 0 just like lists.
So in your current code you would need to add an if
statement just above that print
statement so that if continent[0]
is equal to "A"
then print the continent.
Hope this helps!
Jorge Grajeda
Python Development Techdegree Graduate 8,186 PointsI understand that I should add an IF statement but could you be a little bit more specific?
Jennifer Nordell
Treehouse TeacherJorge Grajeda ok How about this:
if continent[0] == "A":
It should be located inside the for
loop. Your code should contain only one print statement. That print statement should run if the line above evaluates to true.
Hope this helps!
Jason Kampf
4,873 PointsJason Kampf
4,873 PointsHave you got this to work yet? I've been stuck on this same challenge for awhile now.