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

Blue DiamondXD
Blue DiamondXD
5,369 Points

it doesent work help please

help

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

2 Answers

Steven Parker
Steven Parker
216,148 Points

You're kind of close. But your "if" must be indented if you want it to be considered to be inside the loop. And you'll only need one "print" statement.

Blue DiamondXD
Blue DiamondXD
5,369 Points

sooo i need to use a print instead of a if??

Steven Parker
Steven Parker
216,148 Points

You'll need both for task 2. If you have already completed task 1, you should be able to pass task 2 by adding an "if" to control your existing "print" statement (and adjusting the indentation appropriately).

Blue DiamondXD
Blue DiamondXD
5,369 Points

thank you i soved it that you for your time

Hello,

Great job on your Python learning,

So here we want to iterate over the array continents and then print each continent with an asterisk. You have the solution already line 2 and 3 of your code are enough and will solve the first part of the problem.

For the second part of the problem. Before to print anything we want to check to see if the continent we are looping over starts by an "A". So for this part, we will use only the lines 2,3 and 4 of your code and we will move line 4 (the if statement/checking state) before line 3.

Blue DiamondXD
Blue DiamondXD
5,369 Points

thank you i soved it that you for your time