Answer:
Modify your program by replacing
<em>for x in country:
</em>
<em> country_gold.append(gold[x])
</em>
<em> country_gold.append("Did not get gold")</em>
with
<em>for x in country:
</em>
<em> try:
</em>
<em> country_gold.append(gold[x])
</em>
<em> except:
</em>
<em> country_gold.append("Did not get gold")
</em>
<em />
Explanation:
The addition of try/except clause in the program is to let the program manage error;
In this case, the program checks for a country in the list country; This is implemented using the following line
for x in country:
If the country exists, the statement in the try block is executed
<em> try:
</em>
<em> country_gold.append(gold[x]) -></em><em>This appends the country name to the country_gold list</em>
Otherwise, the statement in the except clause is executed
<em> except:
</em>
<em> country_gold.append("Did not get gold") -> </em><em>This appends "Did not get gold" to the country_gold list</em>
<em />
<em>To confirm what you've done, you may add the following line of code at the end of the program: </em>print(country_gold)