The capital city

Report a typo

Your task is to write a view function that takes a country name as an argument in the address bar and then checks whether the country is in the dictionary keys. If it is so, display the corresponding capital city. If not, throw the abort() error handler with 404 and the following description: Resource not found.

Tip: Use abort() with the return.

Write a program in Python 3
from flask import Flask

app = Flask(__name__)

@app.route("/capital/<country>")
def capital(country):

capitals_dictionary = {
"Russia":"Moscow",
"Ukraine":"Kiev",
"USA":"Washington"
}

# your code here checks that the country is on the list, if not, then abort(400)
___

Create a free account to access the full topic