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

I do not understand this question: HINT: Reme

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

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

4 Answers

angel moreta
angel moreta
2,912 Points

you are overthinking the challenge, delete both if statements, then indent the print function inside the loop.

angel moreta
angel moreta
2,912 Points

for task number two: for continent in continents: if 'A' in continent[0]: # you can also do this: 'A' == continent[0] print ("* " + continent)

**** remember the challenge says that you can access characters in a string by index****

You can use python str.startswith to find letters from the beginning of the string.

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

for continent in continents:
    if continent.startswith('A'):
        print("* " + continent)

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

Your code here

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

for letters in continents: if letters[0] == "A": print("* " + letters)