RunestoneServer icon indicating copy to clipboard operation
RunestoneServer copied to clipboard

FOPP Exercise description in Activity: 19.6.6 ActiveCode (ac_exceptions_031)

Open aputtu opened this issue 3 years ago • 1 comments

Hi,

Sorry I couldn't find the code bits here on GitHub. I came across the error in the Coursera Course, also visible here: https://runestone.academy/ns/books/published/fopp/Exceptions/ChapterAssessment.html

The description in Exercise Activity: 19.6.6 ActiveCode (ac_exceptions_031) says: "The following code tries to append the third element of each list in conts to the new list third_countries. Currently, the code does not work. Add a try/except clause so the code runs without errors, and the string ‘Continent does not have 3 countries’ is appended to countries instead of producing an error."

Fix suggestions: The part "appended to countries" should probably be: "appended to third_countries" Also Ethiopia is spelled wrong.

The code says:

conts = [['Spain', 'France', 'Greece', 'Portugal', 'Romania', 'Germany'], ['USA', 'Mexico', 'Canada'], ['Japan', 'China', 'Korea', 'Vietnam', 'Cambodia'], ['Argentina', 'Chile', 'Brazil', 'Ecuador', 'Uruguay', 'Venezuela'], ['Australia'], ['Zimbabwe', 'Morocco', 'Kenya', 'Ethiopa', 'South Africa'], ['Antarctica']]

third_countries = []

for c in conts:

    third_countries.append(c[2])

Great course. Cheers!

aputtu avatar Jul 17 '22 20:07 aputtu