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

Joni Mok
seal-mask
.a{fill-rule:evenodd;}techdegree
Joni Mok
Python Development Techdegree Student 1,893 Points

I cannot figure this out with the second task. I need help!

I tried to put the index that begins with letter "A", but it didn't work. I really am not able to figure this out. I need your help. thank you very much!

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
for continent in continents:
    print("* " + continent[0, 3, 5, 6])

1 Answer

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

Hi there, Joni Mok ! The for loop takes each item and looks at it one at a time. It is assigned to the variable continent. Just like you can use the [] to indicate an index in a list, you can also use the same syntax for strings.

my_string = "Hi, Joni"
print(my_string[4])
# output: "J"

As you are looping through the continents, you need an if statement here. You need to check if continent[0] (the first letter) is equal to "A". Inside the if, use the print statement you had from the previous step of this challenge.

Hope this helps! :sparkles: