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

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

2 Answers

Caleb Newell
Caleb Newell
4,061 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
4,061 Points

Your welcome. Glad to help :)

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!

Caleb Newell
Caleb Newell
4,061 Points

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