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

Jorge Grajeda
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jorge Grajeda
Python Development Techdegree Graduate 8,186 Points

I 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.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
print(continents[0],[3],[5],[6])

print("continents:")
for continent in continents:
    print("* " + continent)

Have you got this to work yet? I've been stuck on this same challenge for awhile now.

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi 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! :sparkles:

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Jorge Grajeda ok :smiley: 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! :sparkles: