Python Flask Basics Welcome to Flask Multiply View

Otec Perez Glass
Otec Perez Glass
7,678 Points

Need help!

Challenge 2

Question

Add a new route to multiply() that has two arguments. Add the same two arguments to the multiply() view. They should have defaults of 5.

I'm not sure what is the BUG in this code

ERROR MESSAGE

Bummer: Didn't get a 200 at /multiply

flask_app.py
from flask import Flask

app = Flask(__name__)


@app.route('/multiply')
@app.route('/multiplication/<num1>/<num2>')
def multiply(num1 = 5, num2 = 5):
    return "{}".format(num1*num2)
Ilse Ackerman
Ilse Ackerman
3,511 Points

Hi Otec! I don't know if this will resolve the issue, but I do spy a typo. (.fomat instead of .format)

Otec Perez Glass
Otec Perez Glass
7,678 Points

Ilse Ackerman hope you are doing well and Thank you

def multiply(num1 = 5, num2 = 5):
    return "{}".format(num1*num2)

But sitll the error message

1 Answer

Your route should be multiply instead of multiplication. I was able to get past task 2 with the following:

@app.route('/multiply')
@app.route('/multiply/<num1>/<num2>')
def multiply(num1 = 5, num2 = 5):
    return "{}".format(5*5)
Daniel Smith
Daniel Smith
10,172 Points

why does this work with .format(5*5) but not .format(num1*num2)?