Python Flask Basics Welcome to Flask Multiply View

Stuck on Challenge 2

I don't fully understand what the question wants me to do
from flask import Flask

app = Flask(__name__)

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

1 Answer

Megan Amendola
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

Hi there! Nice work so far! In part 2 it is asking you first to add another route, so the original @app.route('/multiply') should still be in your code. The new route should have 2 arguments in it like the /add route in the video at 2:50.

Instead of arguments, you just have a route with two 5s in it. to make then arguments, you need to enclose them in <> and give them the name you are using in the function, num1 and num2. You also need to make sure they come in as integers by using int: on each argument like this: <int:num1>.

When you pass your arguments into your function, this is where you can set the default values of 5. Set each variable equal to five: num1=5, num2=5.

Then, inside of your function, you only need to return the result of 5*5 not the whole expression 5 * 5 = 25.

It comes together like this:

def multiply(num1=5, num2=5):
    return str(num1 * num2)