Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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)