Python Introducing Lists Using Lists Continental

Blue DiamondXD
Blue DiamondXD
3,913 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
174,022 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
3,913 Points

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

Steven Parker
Steven Parker
174,022 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
3,913 Points

thank you i soved it that you for your time

Claire Beauvais Lightner
Claire Beauvais Lightner
853 Points

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
3,913 Points

thank you i soved it that you for your time