Python Introducing Lists Using Lists Continental

Elisa Burghard
Elisa Burghard
7,570 Points

Continent starting with A - Challenge It displays as asked but still gives me an error message.

I found a solution in the community and applied it. It displays well in the preview window, but still gives me an error message. UPDATE: After a few reloads of the page it finally accepted the answer. Does anyone know why this happens? It's a bit frustrating when you think you have the right answer and it still shows the error message, so you keep looking for other answers...

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here

print("All Continents:")
for all_continents in continents:
    print("* " + all_continents)

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

2 Answers

Steven Parker
Steven Parker
171,943 Points

The instructions said "to now only print continents that begin with the letter A". But this code is printing the entire list and then the "A"s.

Remove the first loop and you'll pass.

Elisa Burghard
Elisa Burghard
7,570 Points

Actually it always says: Important: In each task of this code challenge, the code you write should be added to the code from the previous task. And it did pass with all the code after reloading and copy pasting it all. That´s why I wondered if that is just a bug... Thank you for taking the time to answer :)

Steven Parker
Steven Parker
171,943 Points

That "added to the code" message is standard. Sometimes, like here, the "added" part means adding to an existing function instead of creating another complete one. What gets added here is the conditional statement.

If you leave both versions there for task 2, you'll get "Bummer: Whoops! I found a country that didn't start with A in your output".

I suppose the requirements could have been a bit more explicit and the validation results should be consistent. If you'd like to submit a bug report for either, you'll find instructions on the Support page.

Elisa Burghard
Elisa Burghard
7,570 Points

Thank you, Steven! I did get that message finding continents not starting with A. I finally did get through even with the part 1 still in there, so that was weird. Maybe I should send a bug report. Thanks again and I hope you have a nice week-end.

Steven Parker
Steven Parker
171,943 Points

Elisa Burghard — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!