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

list challenge:task 2 of 2

having problem finishing the challenge continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']

Your code here

print("continents") for continent in continents: print("* " + continent) continents = [0], [3], [5], [6] print("continents") for continent in continents: print("* " + continent)

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

2 Answers

Dave Harker
PLUS
Dave Harker
Courses Plus Student 15,510 Points

Hi Clayton Sibanda,

In part 2, we have to:

I'd like you to now only print continents that begin with the letter "A".
HINT: Remember that you can access characters in a string by index

Strangely, despite being told:

Important: In each task of this code challenge, the code you write should be added to the code from the previous task.

I found that if I didn't get rid of the code from part 1, it wouldn't accept it. Also the challenge encourages you to use character index in the string. You could try something like:

continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']
# Your code here
# Loop through the continents array
for continent in continents:
    # Check first letter of each continent to check if it is/equals (==) 'A'
    if continent[0] == 'A':
        # If it is 'A' then print it out as per requirement
        print('* ' + continent)  

Good effort! Best of luck moving forward and as always ... happy coding!
Dave :dizzy:

Thanks very much

continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']

Your code here

for continent in continents:' if continent[0] == 'A':

    print('* ' + continent)