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 trial

Python Introducing Lists Using Lists Continental

introducing lists - Challenge Task 2 of 2 - python

Any help completing this one would be greatly appreciated. Still a total coding noob, attempting to memorise the basic terminology but failing miserably.

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
print("{}".format(continents[0]))
print("continents:") 
for a in continents:
    a = a.lower()
    print("* " + continents)

2 Answers

Steven Parker
Steven Parker
231,198 Points

You're getting close, but:

  • you don't need to "print" anything before the loop
  • the "print" inside the loop should use the individual item (a) instead of the whole list
  • you don't need to change the case of the item

I'm sorry, I still don't understand =(].

So I can remove the a = a.lower()?

And which print isn't required? Everything below "print("{}".format(continents[0]))" ?

Steven Parker
Steven Parker
231,198 Points

Yes, you should remove the "a = a.lower()", and the two "print" lines above the loop.

And the last "print" should use the individual "a" instead of "continents".

Ah... nope, I thought I had it. so my code is now:

continents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ] for a in continents: print("* " + a)

But how do I make it so that It's testing the first character to see if it starts with A? surely this is just seeing if there is an A in the entire place name?

Steven Parker
Steven Parker
231,198 Points
    if a[0] == "A":    # test if the first character (index 0) is "A"

Ah, I get it... Thank you again!

I tried doing this but its still failing. I ran my code which is much easier but its still failing, why is it failing? Can you help, I spent a lot of time at this activity My code was: continents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ] for c in continents: if c.startswith("A"): print(c)

Steven Parker
Steven Parker
231,198 Points

For best visibility in the community, post a fresh question rather than posting a new question as a comment to an old answer. And always use Markdown formatting to preserve the appearance of the code.

But it looks like you forgot the print the "bullet" ("*") in front of the names.