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 trialVitthal Dhakane
241 PointsI am not able to print continents which start with letter "A"
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']
Your code here
for continent in continents: if continent[0] == "A": print(continent)
This is what I tried to do
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']
for continent in continents:
print("* " + continent)
3 Answers
Swayam Chidrawar
1,028 Pointscontinents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']
for continent in continents:
if continent[0] == "A":
print("* " + continent)
this should work
Steven Tagawa
Python Development Techdegree Graduate 14,438 PointsHi Vitthal,
You've almost got it! If continents were the single string 'Asia', then continents[0] would be the first character in the string, or 'A'. But continents is a list, so continents[0] is the first item in the list, or the whole word 'Asia'. So to find the first character in continents[0], you would write... ?
(Remember that because a string is like a list of characters, a list of strings is really just like a list of lists.)
Steven Tagawa
Python Development Techdegree Graduate 14,438 PointsOkay, so I went back and re-did this challenge, and it wouldn't work for me either for a quite a while. I finally figured out that you have to ignore the little message that says to add your new code after the existing code. Do NOT do that—delete the code from the first task that prints out the whole list, and make sure that the code you have above is the ONLY code there. That code WILL work. That seems that printing out the whole list again first is what's tripping up the testing routines.