Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Introducing Lists Using Lists Continental

how do i write the code please help

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

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

continents.py

continents = [

'Asia',

'South America',

'North America',

'Africa',

'Europe',

'Antarctica',

'Australia',

]

for continent in continents:

print("* " + continent)

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

for continent in continents: print("* " + continent) Your code looks right. you should check he indentation

nakalkucing
nakalkucing
12,964 Points

Hi Tinashe Steve Chipangura! Am I correct that you need help with the second part of this challenge?

2 Answers

Caleb Newell
Caleb Newell
12,562 Points

Ok! Thanks for the heads up. i will do better.

Caleb Newell
Caleb Newell
12,562 Points

for the second part you might want to try something like this:

for continent in continents:
    if continent[0] == 'A':
        print("* {}".format(continent))

thanks very much hey, it worked

Caleb Newell
Caleb Newell
12,562 Points

Your welcome. Glad to help :)

nakalkucing
nakalkucing
12,964 Points

Hey Caleb Newell! I'm glad to see you want to help, that's great. :) I just want to let you know, it is usually frowned on to just give the answer to the challenge without an explanation of why and how it works.

Happy coding!