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 am not able to understand the error in my code plzzz help

continents are given i needed to print the continents start with "A"

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

1 Answer

kaveri Arkasali I just recently answered this question for another student, but this would be a viable solution:

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

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

This code loops through all of the continents in the array and checks if the character at the 0th index (the first character) is equal to "A", and if that is the case then it will print the content with the asterisk in front of it. Hope this helps! let me know if you need any clarification!